diff options
Diffstat (limited to 'engines/titanic')
1031 files changed, 98041 insertions, 0 deletions
diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp new file mode 100644 index 0000000000..880c93d309 --- /dev/null +++ b/engines/titanic/carry/arm.cpp @@ -0,0 +1,213 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/arm.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CArm, CCarry) + ON_MESSAGE(PuzzleSolvedMsg) + ON_MESSAGE(TranslateObjectMsg) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(MaitreDHappyMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(MouseDragMoveMsg) +END_MESSAGE_MAP() + +CArm::CArm() : CCarry(), _string6("Key"), + _field138(0), _field158(0), _field16C(3), _field170(0), + _armRect(220, 208, 409, 350) { +} + +void CArm::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string6, indent); + file->writeNumberLine(_field138, indent); + file->writeNumberLine(_hookedRect.left, indent); + file->writeNumberLine(_hookedRect.top, indent); + file->writeNumberLine(_hookedRect.right, indent); + file->writeNumberLine(_hookedRect.bottom, indent); + + file->writeQuotedLine(_string7, indent); + file->writeNumberLine(_field158, indent); + file->writeNumberLine(_armRect.left, indent); + file->writeNumberLine(_armRect.top, indent); + file->writeNumberLine(_armRect.right, indent); + file->writeNumberLine(_armRect.bottom, indent); + file->writeNumberLine(_field16C, indent); + file->writeNumberLine(_field170, indent); + + CCarry::save(file, indent); +} + +void CArm::load(SimpleFile *file) { + file->readNumber(); + _string6 = file->readString(); + _field138 = file->readNumber(); + _hookedRect.left = file->readNumber(); + _hookedRect.top = file->readNumber(); + _hookedRect.right = file->readNumber(); + _hookedRect.bottom = file->readNumber(); + + _string7 = file->readString(); + _field158 = file->readNumber(); + _armRect.left = file->readNumber(); + _armRect.top = file->readNumber(); + _armRect.right = file->readNumber(); + _armRect.bottom = file->readNumber(); + _field16C = file->readNumber(); + _field170 = file->readNumber(); + + CCarry::load(file); +} + +bool CArm::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _field138 = 0; + _fieldE0 = 1; + + CString name = getName(); + if (name == "Arm1") { + CActMsg actMsg("LoseArm"); + actMsg.execute("MaitreD"); + CPuzzleSolvedMsg solvedMsg; + solvedMsg.execute("AuditoryCentre"); + } else if (name == "Arm2") { + CPuzzleSolvedMsg solvedMsg; + solvedMsg.execute("Key"); + } + + return true; +} + +bool CArm::TranslateObjectMsg(CTranslateObjectMsg *msg) { + Point newPos(_bounds.left - msg->_delta.x, _bounds.top - msg->_delta.y); + setPosition(newPos); + return true; +} + +bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) { + if (_string6 != "None") { + CShowTextMsg textMsg("The arm is already holding something."); + textMsg.execute("PET"); + return false; + } else if (msg->_other->getName() == "GondolierLeftLever") { + CIsHookedOnMsg hookedMsg(_hookedRect, 0, getName()); + hookedMsg._rect.translate(_bounds.left, _bounds.top); + hookedMsg.execute("GondolierLeftLever"); + + if (hookedMsg._result) { + _string7 = "GondolierLeftLever"; + } else { + petAddToInventory(); + } + } else if (msg->_other->getName() == "GondolierRightLever") { + CIsHookedOnMsg hookedMsg(_hookedRect, 0, getName()); + hookedMsg._rect.translate(_bounds.left, _bounds.top); + hookedMsg.execute("GondolierRightLever"); + + if (hookedMsg._result) { + _string7 = "GondolierRightLever"; + } else { + petAddToInventory(); + } + } + + return true; +} + +bool CArm::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!_fieldE0) { + CShowTextMsg textMsg("You can't get this."); + textMsg.execute("PET"); + } else if (checkStartDragging(msg)) { + _tempPos = msg->_mousePos - _bounds; + setPosition(msg->_mousePos - _tempPos); + + if (!_string7.empty()) { + CActMsg actMsg("Unhook"); + actMsg.execute(_string7); + _string7.clear(); + } + + loadFrame(_visibleFrame); + return true; + } + + return false; +} + +bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) { + CGameObject *petItem; + if (find(getName(), &petItem, FIND_PET)) { + if (!_field158) + playSound("z#47.wav", 100, 0, 0); + if (_string6 == "Key" || _string6 == "AuditoryCentre") { + CGameObject *child = static_cast<CGameObject *>(getFirstChild()); + if (child) { + child->setVisible(true); + petAddToInventory(); + } + + _visibleFrame = _field170; + loadFrame(_visibleFrame); + _string6 = "None"; + petInvChange(); + } + } + + _field158 = 1; + _fieldE0 = 1; + return true; +} + +bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + if (_field158) { + if (_string6 == "Key" || _string6 == "AuditoryCentre") { + CCarry *child = static_cast<CCarry *>(getFirstChild()); + if (child) { + _visibleFrame = _field170; + loadFrame(_visibleFrame); + child->setVisible(true); + child->petAddToInventory(); + } + + _string6 = "None"; + } + } + + return true; +} + +bool CArm::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + setPosition(msg->_mousePos - _tempPos); + + if (_string6 != "None" && compareViewNameTo("FrozenArboretum.Node 5.S")) { + loadFrame(_armRect.contains(msg->_mousePos) ? + _field16C : _visibleFrame); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/arm.h b/engines/titanic/carry/arm.h new file mode 100644 index 0000000000..fc8bba1f08 --- /dev/null +++ b/engines/titanic/carry/arm.h @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ARM_H +#define TITANIC_ARM_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CArm : public CCarry { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); + bool TranslateObjectMsg(CTranslateObjectMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool MaitreDHappyMsg(CMaitreDHappyMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); +private: + CString _string6; + int _field138; + Rect _hookedRect; + CString _string7; + int _field158; + Rect _armRect; + int _field16C; + int _field170; +public: + CLASSDEF; + CArm(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ARM_H */ diff --git a/engines/titanic/carry/auditory_centre.cpp b/engines/titanic/carry/auditory_centre.cpp new file mode 100644 index 0000000000..0bda975a36 --- /dev/null +++ b/engines/titanic/carry/auditory_centre.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/auditory_centre.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAuditoryCentre, CBrain) + ON_MESSAGE(PuzzleSolvedMsg) +END_MESSAGE_MAP() + +void CAuditoryCentre::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBrain::save(file, indent); +} + +void CAuditoryCentre::load(SimpleFile *file) { + file->readNumber(); + CBrain::load(file); +} + +bool CAuditoryCentre::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) { + _fieldE0 = 1; + setVisible(true); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/auditory_centre.h b/engines/titanic/carry/auditory_centre.h new file mode 100644 index 0000000000..6f24e86208 --- /dev/null +++ b/engines/titanic/carry/auditory_centre.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AUDITORY_CENTRE_H +#define TITANIC_AUDITORY_CENTRE_H + +#include "titanic/carry/brain.h" + +namespace Titanic { + +class CAuditoryCentre : public CBrain { + DECLARE_MESSAGE_MAP; + bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AUDITORY_CENTRE_H */ diff --git a/engines/titanic/carry/bowl_ear.cpp b/engines/titanic/carry/bowl_ear.cpp new file mode 100644 index 0000000000..bb5172e580 --- /dev/null +++ b/engines/titanic/carry/bowl_ear.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/bowl_ear.h" + +namespace Titanic { + +void CBowlEar::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CEar::save(file, indent); +} + +void CBowlEar::load(SimpleFile *file) { + file->readNumber(); + CEar::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/bowl_ear.h b/engines/titanic/carry/bowl_ear.h new file mode 100644 index 0000000000..4f2fbea478 --- /dev/null +++ b/engines/titanic/carry/bowl_ear.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BOWL_EAR_H +#define TITANIC_BOWL_EAR_H + +#include "titanic/carry/ear.h" + +namespace Titanic { + +class CBowlEar : public CEar { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BOWL_EAR_H */ diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp new file mode 100644 index 0000000000..8df0de9961 --- /dev/null +++ b/engines/titanic/carry/brain.cpp @@ -0,0 +1,134 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/brain.h" +#include "titanic/game/brain_slot.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CBrain, CCarry) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(VisibleMsg) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(PassOnDragStartMsg) + ON_MESSAGE(PETGainedObjectMsg) +END_MESSAGE_MAP() + +CBrain::CBrain() : CCarry(), _field134(0), _field138(0) { +} + +void CBrain::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writePoint(_pos1, indent); + file->writeNumberLine(_field134, indent); + file->writeNumberLine(_field138, indent); + + CCarry::save(file, indent); +} + +void CBrain::load(SimpleFile *file) { + file->readNumber(); + _pos1 = file->readPoint(); + _field134 = file->readNumber(); + _field138 = file->readNumber(); + + CCarry::load(file); +} + +bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CBrainSlot *slot = static_cast<CBrainSlot *>(msg->_other); + if (slot) { + if (slot->getName() == "CentralCore") { + setVisible(false); + petMoveToHiddenRoom(); + CAddHeadPieceMsg headpieceMsg(getName()); + headpieceMsg.execute("CentralCoreSlot"); + } + else if (!slot->_value1 && slot->getName() == "CentralCoreSlot") { + setVisible(false); + petMoveToHiddenRoom(); + CAddHeadPieceMsg headpieceMsg(getName()); + headpieceMsg.execute(msg->_other); + playSound("z#116.wav", 100, 0, 0); + setPosition(Point(0, 0)); + setVisible(false); + _field134 = 1; + } + + return true; + } + else { + return CCarry::UseWithOtherMsg(msg); + } +} + +bool CBrain::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + return true; +} + +bool CBrain::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) + return false; + + if (_field134) { + CTakeHeadPieceMsg headpieceMsg(getName()); + headpieceMsg.execute("TitaniaControl"); + + _field134 = 0; + setVisible(true); + moveToView(); + + setPosition(Point(msg->_mousePos.x - _bounds.width() / 2, + msg->_mousePos.y - _bounds.height() / 2)); + } + + return CCarry::MouseDragStartMsg(msg); +} + +bool CBrain::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { + if (_field134) { + CTakeHeadPieceMsg headpieceMsg(getName()); + headpieceMsg.execute("TitaniaControl"); + _field134 = 0; + + setVisible(true); + moveToView(); + setPosition(Point(msg->_mousePos.x - _bounds.width() / 2, + msg->_mousePos.y - _bounds.height() / 2)); + } + + return CCarry::PassOnDragStartMsg(msg); +} + +bool CBrain::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + if (!_field138) { + if (getName() == "Perch") { + stateInc38(); + _field138 = 1; + } + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/brain.h b/engines/titanic/carry/brain.h new file mode 100644 index 0000000000..bcba161e27 --- /dev/null +++ b/engines/titanic/carry/brain.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BRAIN_H +#define TITANIC_BRAIN_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CBrain : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); +private: + Point _pos1; + int _field134; + int _field138; +public: + CLASSDEF; + CBrain(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BRAIN_H */ diff --git a/engines/titanic/carry/bridge_piece.cpp b/engines/titanic/carry/bridge_piece.cpp new file mode 100644 index 0000000000..fc845feff0 --- /dev/null +++ b/engines/titanic/carry/bridge_piece.cpp @@ -0,0 +1,95 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/bridge_piece.h" +#include "titanic/game/ship_setting.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CBridgePiece, CCarry) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(PassOnDragStartMsg) +END_MESSAGE_MAP() + +CBridgePiece::CBridgePiece() : CCarry(), _field140(0) { +} + +void CBridgePiece::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string6, indent); + file->writePoint(_pos3, indent); + file->writeNumberLine(_field140, indent); + + CCarry::save(file, indent); +} + +void CBridgePiece::load(SimpleFile *file) { + file->readNumber(); + _string6 = file->readString(); + _pos3 = file->readPoint(); + _field140 = file->readNumber(); + + CCarry::load(file); +} + +bool CBridgePiece::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CShipSetting *shipSetting = static_cast<CShipSetting *>(msg->_other); + if (!shipSetting) { + return CCarry::UseWithOtherMsg(msg); + } else if (shipSetting->_string4 == "NULL") { + petAddToInventory(); + return true; + } else { + setVisible(false); + playSound("z#54.wav", 100, 0, 0); + setPosition(shipSetting->_pos1); + shipSetting->_string4 = getName(); + petMoveToHiddenRoom(); + + CAddHeadPieceMsg headpieceMsg(shipSetting->getName() == _string6 ? + "Enable" : "Disable"); + CSetFrameMsg frameMsg; + + CString name = getName(); + if (name == "ChickenBridge") { + frameMsg._frameNumber = 1; + } else if (name == "FanBridge") { + frameMsg._frameNumber = 2; + } else if (name == "SeasonBridge") { + frameMsg._frameNumber = 3; + } else if (name == "BeamBridge") { + frameMsg._frameNumber = 0; + } + + frameMsg.execute(shipSetting); + headpieceMsg.execute(shipSetting); + return true; + } +} + +bool CBridgePiece::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { + setVisible(true); + moveToView(); + return CCarry::PassOnDragStartMsg(msg); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/bridge_piece.h b/engines/titanic/carry/bridge_piece.h new file mode 100644 index 0000000000..80a1cc98a8 --- /dev/null +++ b/engines/titanic/carry/bridge_piece.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BRIDGE_PIECE_H +#define TITANIC_BRIDGE_PIECE_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CBridgePiece : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); +private: + CString _string6; + Point _pos3; + int _field140; +public: + CLASSDEF; + CBridgePiece(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BRIDGE_PIECE_H */ diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp new file mode 100644 index 0000000000..75b3b6f35b --- /dev/null +++ b/engines/titanic/carry/carry.cpp @@ -0,0 +1,241 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/npcs/character.h" +#include "titanic/npcs/succubus.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CCarry, CGameObject) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(MouseDragMoveMsg) + ON_MESSAGE(MouseDragEndMsg) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(VisibleMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(RemoveFromGameMsg) + ON_MESSAGE(MoveToStartPosMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(PassOnDragStartMsg) +END_MESSAGE_MAP() + +CCarry::CCarry() : CGameObject(), _fieldDC(0), _fieldE0(1), + _field100(0), _field104(0), _field108(0), _field10C(0), + _itemFrame(0), _enterFrame(0), _enterFrameSet(false), _visibleFrame(0), + _string1("None"), + _fullViewName("NULL"), + _string3("That doesn't seem to do anything."), + _string4("It doesn't seem to want this.") { +} + +void CCarry::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writePoint(_origPos, indent); + file->writeQuotedLine(_fullViewName, indent); + file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeQuotedLine(_string3, indent); + file->writeQuotedLine(_string4, indent); + file->writePoint(_tempPos, indent); + file->writeNumberLine(_field104, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_field10C, indent); + file->writeNumberLine(_itemFrame, indent); + file->writeQuotedLine(_string5, indent); + file->writeNumberLine(_enterFrame, indent); + file->writeNumberLine(_enterFrameSet, indent); + file->writeNumberLine(_visibleFrame, indent); + + CGameObject::save(file, indent); +} + +void CCarry::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _origPos = file->readPoint(); + _fullViewName = file->readString(); + _fieldDC = file->readNumber(); + _fieldE0 = file->readNumber(); + _string3 = file->readString(); + _string4 = file->readString(); + _tempPos = file->readPoint(); + _field104 = file->readNumber(); + _field108 = file->readNumber(); + _field10C = file->readNumber(); + _itemFrame = file->readNumber(); + _string5 = file->readString(); + _enterFrame = file->readNumber(); + _enterFrameSet = file->readNumber(); + _visibleFrame = file->readNumber(); + + CGameObject::load(file); +} + +bool CCarry::MouseDragStartMsg(CMouseDragStartMsg *msg) { + CString name = getName(); + + if (_fieldE0) { + if (_visible) { + CShowTextMsg textMsg("You can't get this."); + textMsg.execute("PET"); + } + } else { + if (checkStartDragging(msg)) { + CPassOnDragStartMsg startMsg(msg->_mousePos); + startMsg.execute(this); + return true; + } + } + + return false; +} + +bool CCarry::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + setPosition(msg->_mousePos - _tempPos); + return true; +} + +bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) { + if (msg->_dropTarget) { + if (msg->_dropTarget->isPet()) { + petAddToInventory(); + return true; + } + + CCharacter *npc = static_cast<CCharacter *>(msg->_dropTarget); + if (npc) { + CUseWithCharMsg charMsg(npc); + charMsg.execute(this, nullptr, 0); + return true; + } + + CDropObjectMsg dropMsg(this); + if (dropMsg.execute(msg->_dropTarget)) + return true; + + // Fall back on a use with other message + CUseWithOtherMsg otherMsg(msg->_dropTarget); + if (otherMsg.execute(this, nullptr, 0)) + return true; + } + + CString viewName = getViewFullName(); + if (viewName.empty() || msg->_mousePos.y >= 360) { + sleep(250); + petAddToInventory(); + } else { + setPosition(_origPos); + loadFrame(_itemFrame); + } + + return true; +} + +bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) { + CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + if (succubus) { + CSubAcceptCCarryMsg carryMsg; + carryMsg._item = this; + carryMsg.execute(succubus); + } else { + CShowTextMsg textMsg(_string4); + textMsg.execute("PET"); + petAddToInventory(); + } + + return true; +} + +bool CCarry::LeaveViewMsg(CLeaveViewMsg *msg) { + return true; +} + +bool CCarry::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CShowTextMsg textMsg(_string3); + textMsg.execute("PET"); + + _fullViewName = getViewFullName(); + if (_fullViewName.empty() || _bounds.top >= 360) { + sleep(250); + petAddToInventory(); + } else { + setPosition(_origPos); + } + + return true; +} + +bool CCarry::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + if (msg->_visible && _visibleFrame != -1) + loadFrame(_visibleFrame); + + return true; +} + +bool CCarry::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CCarry::RemoveFromGameMsg(CRemoveFromGameMsg *msg) { + setPosition(Point(0, 0)); + setVisible(false); + + return true; +} + +bool CCarry::MoveToStartPosMsg(CMoveToStartPosMsg *msg) { + setPosition(_origPos); + return true; +} + +bool CCarry::EnterViewMsg(CEnterViewMsg *msg) { + if (!_enterFrameSet) { + loadFrame(_enterFrame); + _enterFrameSet = true; + } + + return true; +} + +bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { + if (_visibleFrame != -1) + loadFrame(_visibleFrame); + + if (msg->_value3) { + _tempPos.x = _bounds.width() / 2; + _tempPos.y = _bounds.height() / 2; + } else { + _tempPos = msg->_mousePos - _bounds; + } + + setPosition(_tempPos - getMousePos()); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h new file mode 100644 index 0000000000..72f4024904 --- /dev/null +++ b/engines/titanic/carry/carry.h @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CARRY_H +#define TITANIC_CARRY_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CCarry : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool RemoveFromGameMsg(CRemoveFromGameMsg *msg); + bool MoveToStartPosMsg(CMoveToStartPosMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); +protected: + CString _string1; + Point _origPos; + CString _fullViewName; + int _fieldDC; + int _fieldE0; + CString _string3; + CString _string4; + Point _tempPos; + int _field100; + int _field104; + int _field108; + int _field10C; + int _itemFrame; + CString _string5; + int _enterFrame; + bool _enterFrameSet; + int _visibleFrame; +public: + CLASSDEF; + CCarry(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CARRY_H */ diff --git a/engines/titanic/carry/carry_parrot.cpp b/engines/titanic/carry/carry_parrot.cpp new file mode 100644 index 0000000000..cf96204122 --- /dev/null +++ b/engines/titanic/carry/carry_parrot.cpp @@ -0,0 +1,237 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/carry_parrot.h" +#include "titanic/core/project_item.h" +#include "titanic/core/room_item.h" +#include "titanic/game/cage.h" +#include "titanic/npcs/parrot.h" +#include "titanic/npcs/succubus.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CCarryParrot, CCarry) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(IsParrotPresentMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(MouseDragEndMsg) + ON_MESSAGE(PassOnDragStartMsg) + ON_MESSAGE(PreEnterViewMsg) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + +CCarryParrot::CCarryParrot() : CCarry(), _string6("PerchedParrot"), + _timerId(0), _field13C(0), _field140(false), _field144(10), + _field148(25), _field14C(0), _field150(8) { +} + +void CCarryParrot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string6, indent); + file->writeNumberLine(_timerId, indent); + file->writeNumberLine(_field13C, indent); + file->writeNumberLine(_field140, indent); + + CCarry::save(file, indent); +} + +void CCarryParrot::load(SimpleFile *file) { + file->readNumber(); + _string6 = file->readString(); + _timerId = file->readNumber(); + _field13C = file->readNumber(); + _field140 = file->readNumber(); + + CCarry::load(file); +} + +bool CCarryParrot::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + CParrot::_v4 = 4; + CActMsg actMsg("Shut"); + actMsg.execute("ParrotCage"); + + return true; +} + +bool CCarryParrot::TimerMsg(CTimerMsg *msg) { + if (CParrot::_v4 == 1 || CParrot::_v4 == 4) { + if (++_field13C >= 30) { + CActMsg actMsg("FreeParrot"); + actMsg.execute(this); + } + } + + return true; +} + +bool CCarryParrot::IsParrotPresentMsg(CIsParrotPresentMsg *msg) { + msg->_value = true; + return true; +} + +bool CCarryParrot::LeaveViewMsg(CLeaveViewMsg *msg) { + if (_visible) { + setVisible(false); + _fieldE0 = 0; + CParrot::_v4 = 2; + } + + return true; +} + +bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) { + stopMovie(); + + if (msg->_mousePos.y >= 360) { + petAddToInventory(); + return true; + } + + if (compareViewNameTo("ParrotLobby.Node 1.N")) { + if (msg->_mousePos.x >= 75 && msg->_mousePos.x <= 565 && + !CParrot::_v2 && !CCage::_v2) { + setVisible(false); + _fieldE0 = 0; + CTreeItem *perchedParrot = findUnder(getRoot(), "PerchedParrot"); + detach(); + addUnder(perchedParrot); + sound8(true); + + CPutParrotBackMsg backMsg(msg->_mousePos.x); + backMsg.execute(perchedParrot); + } else { + setVisible(false); + _fieldE0 = 0; + CParrot::_v4 = 2; + playSound("z#475.wav", 100, 0, 0); + sound8(true); + moveUnder(findRoom()); + + CActMsg actMsg("Shut"); + actMsg.execute("ParrotCage"); + } + } else { + CCharacter *character = static_cast<CCharacter *>(msg->_dropTarget); + if (character) { + CUseWithCharMsg charMsg(character); + charMsg.execute(this, nullptr, 0); + } else { + setVisible(false); + _fieldE0 = 0; + playSound("z#475.wav", 100, 0, 0); + sound8(true); + moveUnder(findRoom()); + } + } + + return true; +} + +bool CCarryParrot::PassOnDragStartMsg(CPassOnDragStartMsg *msg) { + if (CParrot::_v4 != 3) { + moveToView(); + setPosition(Point(0, 0)); + setVisible(true); + playClip("Pick Up", 2); + playClip("Flapping", 1); + + stopTimer(_timerId); + _timerId = addTimer(1000, 1000); + + _field13C = 0; + CParrot::_v4 = 1; + msg->_value3 = 1; + + return CCarry::PassOnDragStartMsg(msg); + } + + CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); + if (npc) + startTalking(npc, 0x446BF); + + _fieldE0 = 0; + playSound("z#475.wav", 100, 0, 0); + moveUnder(findRoom()); + msg->_value4 = 1; + + return true; +} + +bool CCarryParrot::PreEnterViewMsg(CPreEnterViewMsg *msg) { + loadSurface(); + CCarryParrot *parrot = static_cast<CCarryParrot *>(getRoot()->findByName("CarryParrot")); + if (parrot) + parrot->_fieldE0 = 0; + + return true; +} + +bool CCarryParrot::UseWithCharMsg(CUseWithCharMsg *msg) { + CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + if (succubus) + CParrot::_v4 = 3; + + return CCarry::UseWithCharMsg(msg); +} + +bool CCarryParrot::ActMsg(CActMsg *msg) { + if (msg->_action == "FreeParrot" && (CParrot::_v4 == 4 || CParrot::_v4 == 1)) { + CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(_string6)); + if (npc) + startTalking(npc, 0x446BF); + + setVisible(false); + _fieldE0 = 0; + + if (CParrot::_v4 == 4) { + CActMsg actMsg("Shut"); + actMsg.execute("ParrotCage"); + } else { + playSound("z#475.wav", 100, 0, 0); + + if (!_field140) { + CCarry *feathers = static_cast<CCarry *>(getRoot()->findByName("Feathers")); + if (feathers) { + feathers->setVisible(true); + feathers->petAddToInventory(); + } + + _field140 = true; + } + + getPetControl()->removeFromInventory(this); + getPetControl()->setAreaChangeType(1); + moveUnder(getRoom()); + } + + CParrot::_v4 = 2; + stopTimer(_timerId); + _timerId = 0; + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/carry_parrot.h b/engines/titanic/carry/carry_parrot.h new file mode 100644 index 0000000000..2980f26d8a --- /dev/null +++ b/engines/titanic/carry/carry_parrot.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CARRY_PARROT_H +#define TITANIC_CARRY_PARROT_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CCarryParrot : public CCarry { + DECLARE_MESSAGE_MAP; + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool IsParrotPresentMsg(CIsParrotPresentMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + bool PassOnDragStartMsg(CPassOnDragStartMsg *msg); + bool PreEnterViewMsg(CPreEnterViewMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool ActMsg(CActMsg *msg); +private: + CString _string6; + int _timerId; + int _field13C; + bool _field140; + int _field144; + int _field148; + int _field14C; + int _field150; +public: + CLASSDEF; + CCarryParrot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CARRY_PARROT_H */ diff --git a/engines/titanic/carry/central_core.cpp b/engines/titanic/carry/central_core.cpp new file mode 100644 index 0000000000..a50c95abbc --- /dev/null +++ b/engines/titanic/carry/central_core.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/central_core.h" + +namespace Titanic { + +void CCentralCore::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBrain::save(file, indent); +} + +void CCentralCore::load(SimpleFile *file) { + file->readNumber(); + CBrain::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/central_core.h b/engines/titanic/carry/central_core.h new file mode 100644 index 0000000000..9d7bef2c13 --- /dev/null +++ b/engines/titanic/carry/central_core.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CENTRAL_CORE_H +#define TITANIC_CENTRAL_CORE_H + +#include "titanic/carry/brain.h" + +namespace Titanic { + +class CCentralCore : public CBrain { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CENTRAL_CORE_H */ diff --git a/engines/titanic/carry/chicken.cpp b/engines/titanic/carry/chicken.cpp new file mode 100644 index 0000000000..65404dc65d --- /dev/null +++ b/engines/titanic/carry/chicken.cpp @@ -0,0 +1,225 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/chicken.h" +#include "titanic/game/sauce_dispensor.h" +#include "titanic/npcs/succubus.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CChicken, CCarry) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(VisibleMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(ParrotTriesChickenMsg) + ON_MESSAGE(MouseDragEndMsg) + ON_MESSAGE(PETObjectStateMsg) + ON_MESSAGE(PETLostObjectMsg) +END_MESSAGE_MAP() + +int CChicken::_v1; + +CChicken::CChicken() : CCarry(), _string6("None"), + _field12C(1), _field13C(0), _timerId(0) { +} + +void CChicken::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field12C, indent); + file->writeQuotedLine(_string6, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_field13C, indent); + file->writeNumberLine(_timerId, indent); + + CCarry::save(file, indent); +} + +void CChicken::load(SimpleFile *file) { + file->readNumber(); + _field12C = file->readNumber(); + _string6 = file->readString(); + _v1 = file->readNumber(); + _field13C = file->readNumber(); + _timerId = file->readNumber(); + + CCarry::load(file); +} + +bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) { + if (msg->_other->getName() == "Napkin") { + if (_field12C || _string6 == "None") { + CActMsg actMsg("Clean"); + actMsg.execute(this); + petAddToInventory(); + } else { + CShowTextMsg textMsg("The chicken is already clean."); + textMsg.execute("PET"); + } + + petAddToInventory(); + } else { + CSauceDispensor *dispensor = static_cast<CSauceDispensor *>(msg->_other); + if (!dispensor || _string6 == "None") { + return CCarry::UseWithOtherMsg(msg); + } else { + setVisible(false); + CUse use(this); + use.execute(msg->_other); + } + } + + return true; +} + +bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) { + CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_character); + if (succubus) { + setPosition(Point(330, 300)); + CSubAcceptCCarryMsg acceptMsg; + acceptMsg._item = this; + acceptMsg.execute(succubus); + } else { + petAddToInventory(); + } + + return true; +} + +bool CChicken::ActMsg(CActMsg *msg) { + if (msg->_action == "GoToPET") { + setVisible(true); + petAddToInventory(); + } else if (msg->_action == "Tomato") { + _string6 = "Tomato"; + loadFrame(4); + _visibleFrame = 4; + } else if (msg->_action == "Mustard") { + _string6 = "Mustard"; + loadFrame(5); + _visibleFrame = 5; + } else if (msg->_action == "Bird") { + _string6 = "Bird"; + loadFrame(2); + _visibleFrame = 2; + } else if (msg->_action == "None") { + setVisible(false); + } else if (msg->_action == "Clean") { + _string6 = "None"; + loadFrame(3); + _field12C = 0; + _visibleFrame = 3; + } + else if (msg->_action == "Dispense Chicken") { + _string6 = "None"; + _field13C = 0; + _field12C = 1; + loadFrame(1); + _visibleFrame = 1; + _v1 = 120; + } else if (msg->_action == "Hot") { + _v1 = 120; + } else if (msg->_action == "Eaten") { + setVisible(false); + petMoveToHiddenRoom(); + _field13C = 1; + } + + return true; +} + +bool CChicken::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + if (msg->_visible) + loadFrame(_visibleFrame); + + return true; +} + +bool CChicken::TimerMsg(CTimerMsg *msg) { + CGameObject *obj = getMailManFirstObject(); + while (obj && obj->getName() != "Chicken") + obj = getMailManNextObject(obj); + + bool flag = false; + if (obj) { + flag = _v1; + } else if (_v1 > 0) { + --_v1; + flag = _v1; + } + + if (flag) { + petInvChange(); + stopTimer(_timerId); + } + + return true; +} + +bool CChicken::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + stopTimer(_timerId); + _timerId = addTimer(1000, 1000); + return true; +} + +bool CChicken::ParrotTriesChickenMsg(CParrotTriesChickenMsg *msg) { + if (_v1 > 0) + msg->_value1 = 1; + + if (_string6 == "Tomato") { + msg->_value2 = 1; + } else if (_string6 == "Mustard") { + msg->_value2 = 2; + } else if (_string6 == "Bird") { + msg->_value2 = 3; + } + + return true; +} + +bool CChicken::MouseDragEndMsg(CMouseDragEndMsg *msg) { + if (_field13C) + return true; + else + return CCarry::MouseDragEndMsg(msg); +} + +bool CChicken::PETObjectStateMsg(CPETObjectStateMsg *msg) { + if (_v1 > 0) + msg->_value = 2; + + return true; +} + +bool CChicken::PETLostObjectMsg(CPETLostObjectMsg *msg) { + if (compareViewNameTo("ParrotLobby.Node 1.N")) { + CActMsg actMsg("StartChickenDrag"); + actMsg.execute("PerchedParrot"); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/chicken.h b/engines/titanic/carry/chicken.h new file mode 100644 index 0000000000..65fe30fd81 --- /dev/null +++ b/engines/titanic/carry/chicken.h @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHICKEN_H +#define TITANIC_CHICKEN_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CChicken : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool ActMsg(CActMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool ParrotTriesChickenMsg(CParrotTriesChickenMsg *msg); + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + bool PETObjectStateMsg(CPETObjectStateMsg *msg); + bool PETLostObjectMsg(CPETLostObjectMsg *msg); +private: + static int _v1; +public: + int _field12C; + CString _string6; + int _field13C; + int _timerId; +public: + CLASSDEF; + CChicken(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHICKEN_H */ diff --git a/engines/titanic/carry/crushed_tv.cpp b/engines/titanic/carry/crushed_tv.cpp new file mode 100644 index 0000000000..a265b611a9 --- /dev/null +++ b/engines/titanic/carry/crushed_tv.cpp @@ -0,0 +1,80 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/crushed_tv.h" +#include "titanic/npcs/character.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CCrushedTV, CCarry) + ON_MESSAGE(ActMsg) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + +CCrushedTV::CCrushedTV() : CCarry() { +} + +void CCrushedTV::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CCrushedTV::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +bool CCrushedTV::ActMsg(CActMsg *msg) { + if (msg->_action == "SmashTV") { + setVisible(true); + _fieldE0 = 1; + } + + return true; +} + +bool CCrushedTV::UseWithCharMsg(CUseWithCharMsg *msg) { + if (msg->_character->getName() == "Barbot" && msg->_character->_visible) { + setVisible(false); + CActMsg actMsg("CrushedTV"); + actMsg.execute(msg->_character); + return true; + } else { + return CCarry::UseWithCharMsg(msg); + } +} + +bool CCrushedTV::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) { + return false; + } else if (compareViewNameTo("BottomOfWell.Node 7.N")) { + changeView("BottomOfWell.Node 12.N", ""); + CActMsg actMsg("TelevisionTaken"); + actMsg.execute("BOWTelevisionMonitor"); + } + + return CCarry::MouseDragStartMsg(msg); +} + + +} // End of namespace Titanic diff --git a/engines/titanic/carry/crushed_tv.h b/engines/titanic/carry/crushed_tv.h new file mode 100644 index 0000000000..340930f842 --- /dev/null +++ b/engines/titanic/carry/crushed_tv.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CRUSHED_TV_H +#define TITANIC_CRUSHED_TV_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CCrushedTV : public CCarry { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); +public: + CLASSDEF; + CCrushedTV(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CRUSHED_TV_H */ diff --git a/engines/titanic/carry/ear.cpp b/engines/titanic/carry/ear.cpp new file mode 100644 index 0000000000..8d85e247f7 --- /dev/null +++ b/engines/titanic/carry/ear.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/ear.h" + +namespace Titanic { + +CEar::CEar() : CHeadPiece() { +} + +void CEar::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CHeadPiece::save(file, indent); +} + +void CEar::load(SimpleFile *file) { + file->readNumber(); + CHeadPiece::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/ear.h b/engines/titanic/carry/ear.h new file mode 100644 index 0000000000..edef873d35 --- /dev/null +++ b/engines/titanic/carry/ear.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EAR_H +#define TITANIC_EAR_H + +#include "titanic/carry/head_piece.h" + +namespace Titanic { + +class CEar : public CHeadPiece { +public: + CLASSDEF; + CEar(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EAR_H */ diff --git a/engines/titanic/carry/eye.cpp b/engines/titanic/carry/eye.cpp new file mode 100644 index 0000000000..5de1789e54 --- /dev/null +++ b/engines/titanic/carry/eye.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/eye.h" + +namespace Titanic { + +CEye::CEye() : CHeadPiece(), _eyeNum(0) { +} + +void CEye::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_eyeNum, indent); + CHeadPiece::save(file, indent); +} + +void CEye::load(SimpleFile *file) { + file->readNumber(); + _eyeNum = file->readNumber(); + CHeadPiece::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/eye.h b/engines/titanic/carry/eye.h new file mode 100644 index 0000000000..066a85609b --- /dev/null +++ b/engines/titanic/carry/eye.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EYE_H +#define TITANIC_EYE_H + +#include "titanic/carry/head_piece.h" + +namespace Titanic { + +class CEye : public CHeadPiece { +private: + int _eyeNum; +public: + CLASSDEF; + CEye(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EYE_H */ diff --git a/engines/titanic/carry/feathers.cpp b/engines/titanic/carry/feathers.cpp new file mode 100644 index 0000000000..a5d2babfb1 --- /dev/null +++ b/engines/titanic/carry/feathers.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/feathers.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CFeathers, CCarry); + +CFeathers::CFeathers() : CCarry() { +} + +void CFeathers::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CFeathers::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/feathers.h b/engines/titanic/carry/feathers.h new file mode 100644 index 0000000000..7282bcb580 --- /dev/null +++ b/engines/titanic/carry/feathers.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FEATHERS_H +#define TITANIC_FEATHERS_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CFeathers : public CCarry { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CFeathers(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FEATHERS_H */ diff --git a/engines/titanic/carry/fruit.cpp b/engines/titanic/carry/fruit.cpp new file mode 100644 index 0000000000..832dccf45a --- /dev/null +++ b/engines/titanic/carry/fruit.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/fruit.h" + +namespace Titanic { + +CFruit::CFruit() : CCarry(), _field12C(0), + _field130(0), _field134(0), _field138(0) { +} + +void CFruit::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_field130, indent); + file->writeNumberLine(_field134, indent); + file->writeNumberLine(_field138, indent); + + CCarry::save(file, indent); +} + +void CFruit::load(SimpleFile *file) { + file->readNumber(); + _field12C = file->readNumber(); + _field130 = file->readNumber(); + _field134 = file->readNumber(); + _field138 = file->readNumber(); + + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/fruit.h b/engines/titanic/carry/fruit.h new file mode 100644 index 0000000000..93fe920740 --- /dev/null +++ b/engines/titanic/carry/fruit.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FRUIT_H +#define TITANIC_FRUIT_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CFruit : public CCarry { +private: + int _field12C; + int _field130; + int _field134; + int _field138; +public: + CLASSDEF; + CFruit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FRUIT_H */ diff --git a/engines/titanic/carry/glass.cpp b/engines/titanic/carry/glass.cpp new file mode 100644 index 0000000000..051457af03 --- /dev/null +++ b/engines/titanic/carry/glass.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/glass.h" + +namespace Titanic { + +CGlass::CGlass() : CCarry(), _string6("None") { +} + +void CGlass::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string6, indent); + CCarry::save(file, indent); +} + +void CGlass::load(SimpleFile *file) { + file->readNumber(); + _string6 = file->readString(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/glass.h b/engines/titanic/carry/glass.h new file mode 100644 index 0000000000..9f4056b1be --- /dev/null +++ b/engines/titanic/carry/glass.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GLASS_H +#define TITANIC_GLASS_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CGlass : public CCarry { +private: + CString _string6; +public: + CLASSDEF; + CGlass(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GLASS_H */ diff --git a/engines/titanic/carry/hammer.cpp b/engines/titanic/carry/hammer.cpp new file mode 100644 index 0000000000..d3b912184c --- /dev/null +++ b/engines/titanic/carry/hammer.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/hammer.h" + +namespace Titanic { + +CHammer::CHammer() : CCarry() { +} + +void CHammer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CHammer::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/hammer.h b/engines/titanic/carry/hammer.h new file mode 100644 index 0000000000..a455d71434 --- /dev/null +++ b/engines/titanic/carry/hammer.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HAMMER_H +#define TITANIC_HAMMER_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CHammer : public CCarry { +public: + CLASSDEF; + CHammer(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HAMMER_H */ diff --git a/engines/titanic/carry/head_piece.cpp b/engines/titanic/carry/head_piece.cpp new file mode 100644 index 0000000000..ae709644a0 --- /dev/null +++ b/engines/titanic/carry/head_piece.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/head_piece.h" + +namespace Titanic { + +CHeadPiece::CHeadPiece() : CCarry(), _string6("Not Working"), + _field12C(0), _field13C(0) { +} + +void CHeadPiece::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field12C, indent); + file->writeQuotedLine(_string6, indent); + file->writeNumberLine(_field13C, indent); + + CCarry::save(file, indent); +} + +void CHeadPiece::load(SimpleFile *file) { + file->readNumber(); + _field12C = file->readNumber(); + _string6 = file->readString(); + _field13C = file->readNumber(); + + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/head_piece.h b/engines/titanic/carry/head_piece.h new file mode 100644 index 0000000000..05ac772853 --- /dev/null +++ b/engines/titanic/carry/head_piece.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HEAD_PIECE_H +#define TITANIC_HEAD_PIECE_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CHeadPiece : public CCarry { +private: + int _field12C; + CString _string6; + int _field13C; +public: + CLASSDEF; + CHeadPiece(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HEAD_PIECE_H */ diff --git a/engines/titanic/carry/hose.cpp b/engines/titanic/carry/hose.cpp new file mode 100644 index 0000000000..747d58c339 --- /dev/null +++ b/engines/titanic/carry/hose.cpp @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/hose.h" + +namespace Titanic { + +CHoseStatics *CHose::_statics; + +void CHose::init() { + _statics = new CHoseStatics(); +} + +void CHose::deinit() { + delete _statics; +} + +CHose::CHose() : CCarry(), + _string6("Succ-U-Bus auxiliary hose attachment incompatible with sliding glass cover.") { +} + +void CHose::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_statics->_v1, indent); + file->writeQuotedLine(_statics->_v2, indent); + file->writeQuotedLine(_string6, indent); + CCarry::save(file, indent); +} + +void CHose::load(SimpleFile *file) { + file->readNumber(); + _statics->_v1 = file->readNumber(); + _statics->_v2 = file->readString(); + _string6 = file->readString(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/hose.h b/engines/titanic/carry/hose.h new file mode 100644 index 0000000000..ebd45860e8 --- /dev/null +++ b/engines/titanic/carry/hose.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HOSE_H +#define TITANIC_HOSE_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +struct CHoseStatics { + int _v1; + CString _v2; +}; + +class CHose : public CCarry { +protected: + static CHoseStatics *_statics; + + CString _string6; +public: + CLASSDEF; + CHose(); + static void init(); + static void deinit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HOSE_H */ diff --git a/engines/titanic/carry/hose_end.cpp b/engines/titanic/carry/hose_end.cpp new file mode 100644 index 0000000000..c9996437bb --- /dev/null +++ b/engines/titanic/carry/hose_end.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/hose_end.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CHoseEnd, CHose); + +CHoseEnd::CHoseEnd() : CHose() { + _string6 = "Connection refused by remote hose."; +} + +void CHoseEnd::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string6, indent); + CHose::save(file, indent); +} + +void CHoseEnd::load(SimpleFile *file) { + file->readNumber(); + _string6 = file->readString(); + CHose::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/hose_end.h b/engines/titanic/carry/hose_end.h new file mode 100644 index 0000000000..836c94456a --- /dev/null +++ b/engines/titanic/carry/hose_end.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HOSE_END_H +#define TITANIC_HOSE_END_H + +#include "titanic/carry/hose.h" + +namespace Titanic { + +class CHoseEnd : public CHose { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CHoseEnd(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HOSE_END_H */ diff --git a/engines/titanic/carry/key.cpp b/engines/titanic/carry/key.cpp new file mode 100644 index 0000000000..6e947464f1 --- /dev/null +++ b/engines/titanic/carry/key.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/key.h" + +namespace Titanic { + +CKey::CKey() : CCarry() { +} + +void CKey::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CKey::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/key.h b/engines/titanic/carry/key.h new file mode 100644 index 0000000000..8f1600f2b3 --- /dev/null +++ b/engines/titanic/carry/key.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_KEY_H +#define TITANIC_KEY_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CKey : public CCarry { +public: + CLASSDEF; + CKey(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_KEY_H */ diff --git a/engines/titanic/carry/liftbot_head.cpp b/engines/titanic/carry/liftbot_head.cpp new file mode 100644 index 0000000000..bcab8e8574 --- /dev/null +++ b/engines/titanic/carry/liftbot_head.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/liftbot_head.h" + +namespace Titanic { + +CLiftbotHead::CLiftbotHead() : CCarry(), _field12C(0) { +} + +void CLiftbotHead::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field12C, indent); + CCarry::save(file, indent); +} + +void CLiftbotHead::load(SimpleFile *file) { + file->readNumber(); + _field12C = file->readNumber(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/liftbot_head.h b/engines/titanic/carry/liftbot_head.h new file mode 100644 index 0000000000..2fcd6a71f9 --- /dev/null +++ b/engines/titanic/carry/liftbot_head.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LIFTBOT_HEAD_H +#define TITANIC_LIFTBOT_HEAD_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CLiftbotHead : public CCarry { +private: + int _field12C; +public: + CLASSDEF; + CLiftbotHead(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIFTBOT_HEAD_H */ diff --git a/engines/titanic/carry/long_stick.cpp b/engines/titanic/carry/long_stick.cpp new file mode 100644 index 0000000000..ab1e42b81f --- /dev/null +++ b/engines/titanic/carry/long_stick.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/long_stick.h" + +namespace Titanic { + +CLongStick::CLongStick() : CCarry() { +} + +void CLongStick::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CLongStick::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/long_stick.h b/engines/titanic/carry/long_stick.h new file mode 100644 index 0000000000..2ff5b7228e --- /dev/null +++ b/engines/titanic/carry/long_stick.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LONG_STICK_H +#define TITANIC_LONG_STICK_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CLongStick : public CCarry { +public: + CLASSDEF; + CLongStick(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LONG_STICK_H */ diff --git a/engines/titanic/carry/magazine.cpp b/engines/titanic/carry/magazine.cpp new file mode 100644 index 0000000000..cdf92fc707 --- /dev/null +++ b/engines/titanic/carry/magazine.cpp @@ -0,0 +1,93 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/magazine.h" +#include "titanic/npcs/deskbot.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CMagazine, CCarry) + ON_MESSAGE(UseWithCharMsg) + ON_MESSAGE(MouseDoubleClickMsg) + ON_MESSAGE(VisibleMsg) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + +CMagazine::CMagazine() : CCarry() { +} + +void CMagazine::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_field130, indent); + + CCarry::save(file, indent); +} + +void CMagazine::load(SimpleFile *file) { + file->readNumber(); + _field12C = file->readNumber(); + _field130 = file->readNumber(); + + CCarry::load(file); +} + +bool CMagazine::UseWithCharMsg(CUseWithCharMsg *msg) { + CDeskbot *deskbot = static_cast<CDeskbot *>(msg->_character); + if (deskbot) { + if (deskbot->_deskbotActive) { + setVisible(false); + setPosition(Point(1000, 1000)); + CActMsg actMsg("2ndClassUpgrade"); + actMsg.execute("Deskbot"); + } + + return true; + } else { + return CCarry::UseWithCharMsg(msg); + } +} + +bool CMagazine::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + return true; +} + +bool CMagazine::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + return true; +} + +bool CMagazine::UseWithOtherMsg(CUseWithOtherMsg *msg) { + if (msg->_other->getName() == "SwitchOnDeskbot") { + // TODO: other _field108 if + if (false) { + setVisible(false); + setPosition(Point(1000, 1000)); + CActMsg actMsg("2ndClassUpgrade"); + actMsg.execute("Deskbot"); + } + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/magazine.h b/engines/titanic/carry/magazine.h new file mode 100644 index 0000000000..d1db4689ba --- /dev/null +++ b/engines/titanic/carry/magazine.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAGAZINE_H +#define TITANIC_MAGAZINE_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CMagazine : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithCharMsg(CUseWithCharMsg *msg); + bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); + bool UseWithOtherMsg(CUseWithOtherMsg *msg); +private: + int _field12C; + int _field130; +public: + CLASSDEF; + CMagazine(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAGAZINE_H */ diff --git a/engines/titanic/carry/maitred_left_arm.cpp b/engines/titanic/carry/maitred_left_arm.cpp new file mode 100644 index 0000000000..b31c2a6f6d --- /dev/null +++ b/engines/titanic/carry/maitred_left_arm.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/maitred_left_arm.h" + +namespace Titanic { + +void CMaitreDLeftArm::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field174, indent); + CArm::save(file, indent); +} + +void CMaitreDLeftArm::load(SimpleFile *file) { + file->readNumber(); + _field174 = file->readNumber(); + CArm::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/maitred_left_arm.h b/engines/titanic/carry/maitred_left_arm.h new file mode 100644 index 0000000000..8f5090b073 --- /dev/null +++ b/engines/titanic/carry/maitred_left_arm.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LEFT_ARM_H +#define TITANIC_LEFT_ARM_H + +#include "titanic/carry/arm.h" + +namespace Titanic { + +class CMaitreDLeftArm : public CArm { +private: + int _field174; +public: + CLASSDEF; + CMaitreDLeftArm() : CArm(), _field174(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LEFT_ARM_H */ diff --git a/engines/titanic/carry/maitred_right_arm.cpp b/engines/titanic/carry/maitred_right_arm.cpp new file mode 100644 index 0000000000..7030e83c9d --- /dev/null +++ b/engines/titanic/carry/maitred_right_arm.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/maitred_right_arm.h" + +namespace Titanic { + +void CMaitreDRightArm::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CArm::save(file, indent); +} + +void CMaitreDRightArm::load(SimpleFile *file) { + file->readNumber(); + CArm::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/maitred_right_arm.h b/engines/titanic/carry/maitred_right_arm.h new file mode 100644 index 0000000000..ce07ed7af4 --- /dev/null +++ b/engines/titanic/carry/maitred_right_arm.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAITRED_RIGHT_ARM_H +#define TITANIC_MAITRED_RIGHT_ARM_H + +#include "titanic/carry/arm.h" + +namespace Titanic { + +class CMaitreDRightArm : public CArm { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAITRED_RIGHT_ARM_H */ diff --git a/engines/titanic/carry/mouth.cpp b/engines/titanic/carry/mouth.cpp new file mode 100644 index 0000000000..8c3791fa9c --- /dev/null +++ b/engines/titanic/carry/mouth.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/mouth.h" + +namespace Titanic { + +CMouth::CMouth() : CHeadPiece() { +} + +void CMouth::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CHeadPiece::save(file, indent); +} + +void CMouth::load(SimpleFile *file) { + file->readNumber(); + CHeadPiece::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/mouth.h b/engines/titanic/carry/mouth.h new file mode 100644 index 0000000000..e394330494 --- /dev/null +++ b/engines/titanic/carry/mouth.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOUTH_H +#define TITANIC_MOUTH_H + +#include "titanic/carry/head_piece.h" + +namespace Titanic { + +class CMouth : public CHeadPiece { +public: + CLASSDEF; + CMouth(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOUTH_H */ diff --git a/engines/titanic/carry/napkin.cpp b/engines/titanic/carry/napkin.cpp new file mode 100644 index 0000000000..ace5a389a0 --- /dev/null +++ b/engines/titanic/carry/napkin.cpp @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/napkin.h" +#include "titanic/carry/chicken.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CNapkin, CCarry) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + +CNapkin::CNapkin() : CCarry() { +} + +void CNapkin::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CNapkin::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CChicken *chicken = static_cast<CChicken *>(msg->_other); + if (chicken) { + if (chicken->_string6 == "None" || chicken->_field12C) { + CActMsg actMsg("Clean"); + actMsg.execute("Chicken"); + } else { + petDisplayMessage("The Chicken is already quite clean enough, thank you."); + } + } + + petAddToInventory(); + return CCarry::UseWithOtherMsg(msg); +} + + +} // End of namespace Titanic diff --git a/engines/titanic/carry/napkin.h b/engines/titanic/carry/napkin.h new file mode 100644 index 0000000000..ce47dd6059 --- /dev/null +++ b/engines/titanic/carry/napkin.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NAPKIN_H +#define TITANIC_NAPKIN_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CNapkin : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); +public: + CLASSDEF; + CNapkin(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NAPKIN_H */ diff --git a/engines/titanic/carry/nose.cpp b/engines/titanic/carry/nose.cpp new file mode 100644 index 0000000000..4f3afe24ac --- /dev/null +++ b/engines/titanic/carry/nose.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/nose.h" + +namespace Titanic { + +CNose::CNose() : CHeadPiece() { +} + +void CNose::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CHeadPiece::save(file, indent); +} + +void CNose::load(SimpleFile *file) { + file->readNumber(); + CHeadPiece::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/nose.h b/engines/titanic/carry/nose.h new file mode 100644 index 0000000000..b688da231a --- /dev/null +++ b/engines/titanic/carry/nose.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NOSE_H +#define TITANIC_NOSE_H + +#include "titanic/carry/head_piece.h" + +namespace Titanic { + +class CNose : public CHeadPiece { +public: + CLASSDEF; + CNose(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NOSE_H */ diff --git a/engines/titanic/carry/note.cpp b/engines/titanic/carry/note.cpp new file mode 100644 index 0000000000..388f87e638 --- /dev/null +++ b/engines/titanic/carry/note.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/note.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CNote, CCarry) + ON_MESSAGE(MouseDoubleClickMsg) +END_MESSAGE_MAP() + +CNote::CNote() : CCarry(), _field138(1) { +} + +void CNote::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string6, indent); + file->writeNumberLine(_field138, indent); + + CCarry::save(file, indent); +} + +void CNote::load(SimpleFile *file) { + file->readNumber(); + _string6 = file->readString(); + _field138 = file->readNumber(); + + CCarry::load(file); +} + +bool CNote::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/note.h b/engines/titanic/carry/note.h new file mode 100644 index 0000000000..37ebf96d72 --- /dev/null +++ b/engines/titanic/carry/note.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NOTE_H +#define TITANIC_NOTE_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CNote : public CCarry { + DECLARE_MESSAGE_MAP; + bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); +private: + CString _string6; + int _field138; +public: + CLASSDEF; + CNote(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NOTE_H */ diff --git a/engines/titanic/carry/parcel.cpp b/engines/titanic/carry/parcel.cpp new file mode 100644 index 0000000000..2ffe8b0aac --- /dev/null +++ b/engines/titanic/carry/parcel.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/parcel.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CParcel, CCarry); + +CParcel::CParcel() : CCarry() { +} + +void CParcel::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CParcel::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/parcel.h b/engines/titanic/carry/parcel.h new file mode 100644 index 0000000000..f33c2ff65a --- /dev/null +++ b/engines/titanic/carry/parcel.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARCEL_H +#define TITANIC_PARCEL_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CParcel : public CCarry { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CParcel(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARCEL_H */ diff --git a/engines/titanic/carry/perch.cpp b/engines/titanic/carry/perch.cpp new file mode 100644 index 0000000000..281b3fce53 --- /dev/null +++ b/engines/titanic/carry/perch.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/perch.h" + +namespace Titanic { + +void CPerch::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCentralCore::save(file, indent); +} + +void CPerch::load(SimpleFile *file) { + file->readNumber(); + CCentralCore::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/perch.h b/engines/titanic/carry/perch.h new file mode 100644 index 0000000000..d23868d909 --- /dev/null +++ b/engines/titanic/carry/perch.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PERCH_H +#define TITANIC_PERCH_H + +#include "titanic/carry/central_core.h" + +namespace Titanic { + +class CPerch : public CCentralCore { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PERCH_H */ diff --git a/engines/titanic/carry/phonograph_cylinder.cpp b/engines/titanic/carry/phonograph_cylinder.cpp new file mode 100644 index 0000000000..0684c56611 --- /dev/null +++ b/engines/titanic/carry/phonograph_cylinder.cpp @@ -0,0 +1,178 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/phonograph_cylinder.h" +#include "titanic/game/phonograph.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPhonographCylinder, CCarry) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(QueryCylinderMsg) + ON_MESSAGE(RecordOntoCylinderMsg) + ON_MESSAGE(SetMusicControlsMsg) + ON_MESSAGE(ErasePhonographCylinderMsg) +END_MESSAGE_MAP() + +CPhonographCylinder::CPhonographCylinder() : CCarry(), + _bellsMuteControl(false), _bellsPitchControl(false), + _bellsSpeedControl(false), _bellsDirectionControl(false), + _bellsInversionControl(false), _snakeMuteControl(false), + _snakeSpeedControl(false), _snakePitchControl(false), + _snakeInversionControl(false), _snakeDirectionControl(false), + _pianoMuteControl(false), _pianoSpeedControl(false), + _pianoPitchControl(false), _pianoInversionControl(false), + _pianoDirectionControl(false), _bassMuteControl(false), + _bassSpeedControl(false), _bassPitchControl(false), + _bassInversionControl(false) { +} + +void CPhonographCylinder::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_itemName, indent); + file->writeNumberLine(_bellsMuteControl, indent); + file->writeNumberLine(_bellsPitchControl, indent); + file->writeNumberLine(_bellsSpeedControl, indent); + file->writeNumberLine(_bellsDirectionControl, indent); + file->writeNumberLine(_bellsInversionControl, indent); + file->writeNumberLine(_snakeMuteControl, indent); + file->writeNumberLine(_snakeSpeedControl, indent); + file->writeNumberLine(_snakePitchControl, indent); + file->writeNumberLine(_snakeInversionControl, indent); + file->writeNumberLine(_snakeDirectionControl, indent); + file->writeNumberLine(_pianoMuteControl, indent); + file->writeNumberLine(_pianoSpeedControl, indent); + file->writeNumberLine(_pianoPitchControl, indent); + file->writeNumberLine(_pianoInversionControl, indent); + file->writeNumberLine(_pianoDirectionControl, indent); + file->writeNumberLine(_bassMuteControl, indent); + file->writeNumberLine(_bassSpeedControl, indent); + file->writeNumberLine(_bassPitchControl, indent); + file->writeNumberLine(_bassInversionControl, indent); + file->writeNumberLine(_bassDirectionControl, indent); + + CCarry::save(file, indent); +} + +void CPhonographCylinder::load(SimpleFile *file) { + file->readNumber(); + _itemName = file->readString(); + _bellsMuteControl = file->readNumber(); + _bellsPitchControl = file->readNumber(); + _bellsSpeedControl = file->readNumber(); + _bellsDirectionControl = file->readNumber(); + _bellsInversionControl = file->readNumber(); + _snakeMuteControl = file->readNumber(); + _snakeSpeedControl = file->readNumber(); + _snakePitchControl = file->readNumber(); + _snakeInversionControl = file->readNumber(); + _snakeDirectionControl = file->readNumber(); + _pianoMuteControl = file->readNumber(); + _pianoSpeedControl = file->readNumber(); + _pianoPitchControl = file->readNumber(); + _pianoInversionControl = file->readNumber(); + _pianoDirectionControl = file->readNumber(); + _bassMuteControl = file->readNumber(); + _bassSpeedControl = file->readNumber(); + _bassPitchControl = file->readNumber(); + _bassInversionControl = file->readNumber(); + _bassDirectionControl = file->readNumber(); + + CCarry::load(file); +} + +bool CPhonographCylinder::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CPhonograph *phonograph = static_cast<CPhonograph *>(msg->_other); + if (phonograph) { + CSetVarMsg varMsg("m_RecordStatus", 1); + return true; + } else { + return CCarry::UseWithOtherMsg(msg); + } +} + +bool CPhonographCylinder::QueryCylinderMsg(CQueryCylinderMsg *msg) { + msg->_name = _itemName; + return true; +} + +bool CPhonographCylinder::RecordOntoCylinderMsg(CRecordOntoCylinderMsg *msg) { + _itemName = "STMusic"; + + CQueryMusicControlSettingMsg queryMsg; + queryMsg.execute("Bells Mute Control"); + _bellsMuteControl = queryMsg._value; + queryMsg.execute("Bells Pitch Control"); + _bellsPitchControl = queryMsg._value; + queryMsg.execute("Bells Speed Control"); + _bellsSpeedControl = queryMsg._value; + queryMsg.execute("Bells Direction Control"); + _bellsDirectionControl = queryMsg._value; + queryMsg.execute("Bells Inversion Control"); + _bellsInversionControl = queryMsg._value; + queryMsg.execute("Snake Mute Control"); + _snakeMuteControl = queryMsg._value; + queryMsg.execute("Snake Speed Control"); + _snakeSpeedControl = queryMsg._value; + queryMsg.execute("Snake Pitch Control"); + _snakePitchControl = queryMsg._value; + queryMsg.execute("Snake Inversion Control"); + _snakeInversionControl = queryMsg._value; + queryMsg.execute("Snake Direction Control"); + _snakeDirectionControl = queryMsg._value; + queryMsg.execute("Piano Mute Control"); + _pianoMuteControl = queryMsg._value; + queryMsg.execute("Piano Speed Control"); + _pianoSpeedControl = queryMsg._value; + queryMsg.execute("Piano Pitch Control"); + _pianoPitchControl = queryMsg._value; + queryMsg.execute("Piano Inversion Control"); + _pianoInversionControl = queryMsg._value; + queryMsg.execute("Piano Direction Control"); + _pianoDirectionControl = queryMsg._value; + queryMsg.execute("Bass Mute Control"); + _bassMuteControl = queryMsg._value; + queryMsg.execute("Bass Speed Control"); + _bassSpeedControl = queryMsg._value; + queryMsg.execute("Bass Pitch Control"); + _bassPitchControl = queryMsg._value; + queryMsg.execute("Bass Inversion Control"); + _bassInversionControl = queryMsg._value; + + return true; +} + +bool CPhonographCylinder::SetMusicControlsMsg(CSetMusicControlsMsg *msg) { + if (_itemName.left(7) == "STMusic") { + //todo + warning("TODO"); + } + + return true; +} + +bool CPhonographCylinder::ErasePhonographCylinderMsg(CErasePhonographCylinderMsg *msg) { + _itemName.clear(); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/phonograph_cylinder.h b/engines/titanic/carry/phonograph_cylinder.h new file mode 100644 index 0000000000..bbb1524cb5 --- /dev/null +++ b/engines/titanic/carry/phonograph_cylinder.h @@ -0,0 +1,76 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PHONOGRAPH_CYLINDER_H +#define TITANIC_PHONOGRAPH_CYLINDER_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CPhonographCylinder : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool QueryCylinderMsg(CQueryCylinderMsg *msg); + bool RecordOntoCylinderMsg(CRecordOntoCylinderMsg *msg); + bool SetMusicControlsMsg(CSetMusicControlsMsg *msg); + bool ErasePhonographCylinderMsg(CErasePhonographCylinderMsg *msg); +private: + CString _itemName; + bool _bellsMuteControl; + bool _bellsPitchControl; + bool _bellsSpeedControl; + bool _bellsDirectionControl; + bool _bellsInversionControl; + bool _snakeMuteControl; + bool _snakeSpeedControl; + bool _snakePitchControl; + bool _snakeInversionControl; + bool _snakeDirectionControl; + bool _pianoMuteControl; + bool _pianoSpeedControl; + bool _pianoPitchControl; + bool _pianoInversionControl; + bool _pianoDirectionControl; + bool _bassMuteControl; + bool _bassSpeedControl; + bool _bassPitchControl; + bool _bassInversionControl; + bool _bassDirectionControl; +public: + CLASSDEF; + CPhonographCylinder(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PHONOGRAPH_CYLINDER_H */ diff --git a/engines/titanic/carry/phonograph_ear.cpp b/engines/titanic/carry/phonograph_ear.cpp new file mode 100644 index 0000000000..ceb71babd2 --- /dev/null +++ b/engines/titanic/carry/phonograph_ear.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/phonograph_ear.h" + +namespace Titanic { + +void CPhonographEar::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field140, indent); + CEar::save(file, indent); +} + +void CPhonographEar::load(SimpleFile *file) { + file->readNumber(); + _field140 = file->readNumber(); + CEar::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/phonograph_ear.h b/engines/titanic/carry/phonograph_ear.h new file mode 100644 index 0000000000..582db9f7ef --- /dev/null +++ b/engines/titanic/carry/phonograph_ear.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PHONOGRAPH_EAR_H +#define TITANIC_PHONOGRAPH_EAR_H + +#include "titanic/carry/ear.h" + +namespace Titanic { + +class CPhonographEar : public CEar { +private: + int _field140; +public: + CLASSDEF; + CPhonographEar() : CEar(), _field140(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PHONOGRAPH_EYE_H */ diff --git a/engines/titanic/carry/photograph.cpp b/engines/titanic/carry/photograph.cpp new file mode 100644 index 0000000000..7f32a0623d --- /dev/null +++ b/engines/titanic/carry/photograph.cpp @@ -0,0 +1,98 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/photograph.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPhotograph, CCarry) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(MouseDragEndMsg) + ON_MESSAGE(PETGainedObjectMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + +int CPhotograph::_v1; + +CPhotograph::CPhotograph() : CCarry(), _field12C(0), _field130(0) { +} + +void CPhotograph::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_field130, indent); + + CCarry::save(file, indent); +} + +void CPhotograph::load(SimpleFile *file) { + file->readNumber(); + _field12C = file->readNumber(); + _v1 = file->readNumber(); + _field130 = file->readNumber(); + + CCarry::load(file); +} + +bool CPhotograph::MouseDragEndMsg(CMouseDragEndMsg *msg) { + _v1 = 0; + CGameObject *target = msg->_dropTarget; + + if (target && target->getName() != "NavigationComputer") { + warning("TODO: CPhotograph::MouseDragEndMsg"); + return true; + } else { + return CCarry::MouseDragEndMsg(msg); + } +} + +bool CPhotograph::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (checkPoint(msg->_mousePos, true, true)) { + _v1 = true; + CActMsg actMsg("PlayerPicksUpPhoto"); + actMsg.execute("Doorbot"); + } + + return CCarry::MouseDragStartMsg(msg); +} + +bool CPhotograph::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + if (getRoom()->getName() == "Home") { + CActMsg actMsg("PlayerPutsPhotoInPET"); + actMsg.execute("Doorbot"); + } + + return true; +} + +bool CPhotograph::ActMsg(CActMsg *msg) { + if (msg->_action == "BecomeGettable") { + _fieldE0 = 1; + _cursorId = CURSOR_HAND; + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/photograph.h b/engines/titanic/carry/photograph.h new file mode 100644 index 0000000000..9cea1e4799 --- /dev/null +++ b/engines/titanic/carry/photograph.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PHOTOGRAPH_H +#define TITANIC_PHOTOGRAPH_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CPhotograph : public CCarry { + DECLARE_MESSAGE_MAP; + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); + bool ActMsg(CActMsg *msg); +private: + static int _v1; +private: + int _field12C; + int _field130; +public: + CLASSDEF; + CPhotograph(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PHOTOGRAPH_H */ diff --git a/engines/titanic/carry/plug_in.cpp b/engines/titanic/carry/plug_in.cpp new file mode 100644 index 0000000000..c82a4cc422 --- /dev/null +++ b/engines/titanic/carry/plug_in.cpp @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/plug_in.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPlugIn, CCarry) + ON_MESSAGE(UseWithOtherMsg) +END_MESSAGE_MAP() + +CPlugIn::CPlugIn() : CCarry(), _field12C(0) { +} + +void CPlugIn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CPlugIn::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +bool CPlugIn::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CGameObject *other = msg->_other; + CString otherName = other->getName(); + + if (otherName == "PET") { + return CCarry::UseWithOtherMsg(msg); + } else if (otherName == "DatasideTransporter") { + CString name = getName(); + if (name == "DatasideTransporter") { + // TODO + if (name != "SendYourself") { + // TODO + } + } else { + // TODO + } + } else { + CShowTextMsg textMsg("This item is incorrectly calibrated."); + textMsg.execute("PET"); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/plug_in.h b/engines/titanic/carry/plug_in.h new file mode 100644 index 0000000000..1358a99e39 --- /dev/null +++ b/engines/titanic/carry/plug_in.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PLUG_IN_H +#define TITANIC_PLUG_IN_H + +#include "titanic/carry/carry.h" + +namespace Titanic { + +class CPlugIn : public CCarry { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); +private: + int _field12C; +public: + CLASSDEF; + CPlugIn(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PLUG_IN_H */ diff --git a/engines/titanic/carry/speech_centre.cpp b/engines/titanic/carry/speech_centre.cpp new file mode 100644 index 0000000000..b8076aee76 --- /dev/null +++ b/engines/titanic/carry/speech_centre.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/speech_centre.h" + +namespace Titanic { + +void CSpeechCentre::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field13C, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_field14C, indent); + + CBrain::save(file, indent); +} + +void CSpeechCentre::load(SimpleFile *file) { + file->readNumber(); + _field13C = file->readNumber(); + _string1 = file->readString(); + _field14C = file->readNumber(); + + CBrain::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/speech_centre.h b/engines/titanic/carry/speech_centre.h new file mode 100644 index 0000000000..50f47e9c8a --- /dev/null +++ b/engines/titanic/carry/speech_centre.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SPEECH_CENTRE_H +#define TITANIC_SPEECH_CENTRE_H + +#include "titanic/carry/brain.h" + +namespace Titanic { + +class CSpeechCentre : public CBrain { +private: + int _field13C; + CString _string1; + int _field14C; +public: + CLASSDEF; + CSpeechCentre() : CBrain(), _string1("Summer"), + _field13C(1), _field14C(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SPEECH_CENTRE_H */ diff --git a/engines/titanic/carry/sweets.cpp b/engines/titanic/carry/sweets.cpp new file mode 100644 index 0000000000..f19a8287b7 --- /dev/null +++ b/engines/titanic/carry/sweets.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/sweets.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CSweets, CCarry) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + +CSweets::CSweets() : CCarry() { +} + +void CSweets::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CCarry::save(file, indent); +} + +void CSweets::load(SimpleFile *file) { + file->readNumber(); + CCarry::load(file); +} + +bool CSweets::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/sweets.h b/engines/titanic/carry/sweets.h new file mode 100644 index 0000000000..3655fabfb9 --- /dev/null +++ b/engines/titanic/carry/sweets.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SWEETS_H +#define TITANIC_SWEETS_H + +#include "titanic/carry/carry.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CSweets : public CCarry { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); +public: + CLASSDEF; + CSweets(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SWEETS_H */ diff --git a/engines/titanic/carry/vision_centre.cpp b/engines/titanic/carry/vision_centre.cpp new file mode 100644 index 0000000000..8c8bab15f8 --- /dev/null +++ b/engines/titanic/carry/vision_centre.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/vision_centre.h" + +namespace Titanic { + +void CVisionCentre::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBrain::save(file, indent); +} + +void CVisionCentre::load(SimpleFile *file) { + file->readNumber(); + CBrain::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/carry/vision_centre.h b/engines/titanic/carry/vision_centre.h new file mode 100644 index 0000000000..6cf8e2c653 --- /dev/null +++ b/engines/titanic/carry/vision_centre.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_VISION_CENTRE_H +#define TITANIC_VISION_CENTRE_H + +#include "titanic/carry/brain.h" + +namespace Titanic { + +class CVisionCentre : public CBrain { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_VISION_CENTRE_H */ diff --git a/engines/titanic/configure.engine b/engines/titanic/configure.engine new file mode 100644 index 0000000000..daf4e6b388 --- /dev/null +++ b/engines/titanic/configure.engine @@ -0,0 +1,3 @@ +# This file is included from the main "configure" script +# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] +add_engine titanic "Starship Titanic" no "" "" "16bit jpeg highres" diff --git a/engines/titanic/continue_save_dialog.cpp b/engines/titanic/continue_save_dialog.cpp new file mode 100644 index 0000000000..39b7d1942a --- /dev/null +++ b/engines/titanic/continue_save_dialog.cpp @@ -0,0 +1,224 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/continue_save_dialog.h" +#include "titanic/titanic.h" + +namespace Titanic { + +#define SAVEGAME_SLOTS_COUNT 5 +#define RESTORE_X 346 +#define RESTORE_Y 94 +#define START_X 370 +#define START_Y 276 + +CContinueSaveDialog::CContinueSaveDialog() { + g_vm->_events->addTarget(this); + _highlightedSlot = _selectedSlot = -999; + _restoreState = _startState = -1; + _mouseDown = false; + _evilTwinShown = false; + + for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) { + Rect slotRect = getSlotBounds(idx); + _slotNames[idx].setFontNumber(0); + _slotNames[idx].setBounds(slotRect); + _slotNames[idx].resize(3); + _slotNames[idx].setMaxCharsPerLine(22); + _slotNames[idx].setHasBorder(false); + _slotNames[idx].setup(); + } +} + +CContinueSaveDialog::~CContinueSaveDialog() { + g_vm->_events->removeTarget(); +} + +void CContinueSaveDialog::addSavegame(int slot, const CString &name) { + assert(_saves.size() < SAVEGAME_SLOTS_COUNT); + _slotNames[_saves.size()].setText(name); + _saves.push_back(SaveEntry(slot, name)); +} + +Rect CContinueSaveDialog::getSlotBounds(int index) { + return Rect(360, 164 + index * 19, 556, 180 + index * 19); +} + +int CContinueSaveDialog::show() { + // Load images for the dialog + loadImages(); + + // Render the view + render(); + + // Event loop waiting for selection + while (!g_vm->shouldQuit() && _selectedSlot == -999) { + g_vm->_events->pollEventsAndWait(); + } + + return _selectedSlot; +} + +void CContinueSaveDialog::loadImages() { + _backdrop.load("Bitmap/BACKDROP"); + _evilTwin.load("Bitmap/EVILTWIN"); + _restoreD.load("Bitmap/RESTORED"); + _restoreU.load("Bitmap/RESTOREU"); + _restoreF.load("Bitmap/RESTOREF"); + _startD.load("Bitmap/STARTD"); + _startU.load("Bitmap/STARTU"); + _startF.load("Bitmap/STARTF"); +} + +void CContinueSaveDialog::render() { + Graphics::Screen &screen = *g_vm->_screen; + screen.clear(); + screen.blitFrom(_backdrop, Common::Point(48, 22)); + + if (_evilTwinShown) + screen.blitFrom(_evilTwin, Common::Point(78, 59)); + + _restoreState = _startState = -1; + renderButtons(); + renderSlots(); +} + +void CContinueSaveDialog::renderButtons() { + Graphics::Screen &screen = *g_vm->_screen; + Rect restoreRect(RESTORE_X, RESTORE_Y, RESTORE_X + _restoreU.w, RESTORE_Y + _restoreU.h); + Rect startRect(START_X, START_Y, START_X + _startU.w, START_Y + _startU.h); + + // Determine the current state for the buttons + int restoreState, startState; + if (!restoreRect.contains(_mousePos)) + restoreState = 0; + else + restoreState = _mouseDown ? 1 : 2; + + if (!startRect.contains(_mousePos)) + startState = 0; + else + startState = _mouseDown ? 1 : 2; + + // Draw the start button + if (startState != _startState) { + _startState = startState; + switch (_startState) { + case 0: + screen.blitFrom(_startU, Common::Point(START_X, START_Y)); + break; + case 1: + screen.blitFrom(_startD, Common::Point(START_X, START_Y)); + break; + case 2: + screen.blitFrom(_startF, Common::Point(START_X, START_Y)); + break; + default: + break; + } + } + + // Draw the restore button + if (restoreState != _restoreState) { + _restoreState = restoreState; + switch (_restoreState) { + case 0: + screen.blitFrom(_restoreU, Common::Point(RESTORE_X, RESTORE_Y)); + break; + case 1: + screen.blitFrom(_restoreD, Common::Point(RESTORE_X, RESTORE_Y)); + break; + case 2: + screen.blitFrom(_restoreF, Common::Point(RESTORE_X, RESTORE_Y)); + break; + default: + break; + } + } +} + +void CContinueSaveDialog::renderSlots() { + for (int idx = 0; idx < (int)_saves.size(); ++idx) { + byte rgb = (_highlightedSlot == idx) ? 255 : 0; + _slotNames[idx].setColor(rgb, rgb, rgb); + _slotNames[idx].setLineColor(0, rgb, rgb, rgb); + _slotNames[idx].draw(CScreenManager::_screenManagerPtr); + } +} + +void CContinueSaveDialog::mouseMove(const Point &mousePos) { + _mousePos = mousePos; + renderButtons(); +} + +void CContinueSaveDialog::leftButtonDown(const Point &mousePos) { + _mouseDown = true; + mouseMove(mousePos); +} + +void CContinueSaveDialog::leftButtonUp(const Point &mousePos) { + Rect restoreRect(RESTORE_X, RESTORE_Y, RESTORE_X + _restoreU.w, RESTORE_Y + _restoreU.h); + Rect startRect(START_X, START_Y, START_X + _startU.w, START_Y + _startU.h); + _mouseDown = false; + + if (restoreRect.contains(mousePos)) { + // Flag to exit dialog and load highlighted slot. If no slot was + // selected explicitly, then fall back on loading the first slot + _selectedSlot = (_highlightedSlot == -999) ? _saves[0]._slot : + _saves[_highlightedSlot]._slot; + } else if (startRect.contains(mousePos)) { + // Start a new game + _selectedSlot = -1; + } else { + // Check whether a filled in slot was selected + for (uint idx = 0; idx < _saves.size(); ++idx) { + if (getSlotBounds(idx).contains(mousePos)) { + _highlightedSlot = idx; + render(); + break; + } + } + } +} + +void CContinueSaveDialog::rightButtonDown(const Point &mousePos) { + Rect eye1(188, 190, 192, 195), eye2(209, 192, 213, 197); + + if (eye1.contains(mousePos) || eye2.contains(mousePos)) { + _evilTwinShown = true; + render(); + } +} + +void CContinueSaveDialog::rightButtonUp(const Point &mousePos) { + if (_evilTwinShown) { + _evilTwinShown = false; + render(); + } +} + +void CContinueSaveDialog::keyDown(Common::KeyState keyState) { + if (keyState.keycode == Common::KEYCODE_ESCAPE) + _selectedSlot = EXIT_GAME; +} + +} // End of namespace Titanic diff --git a/engines/titanic/continue_save_dialog.h b/engines/titanic/continue_save_dialog.h new file mode 100644 index 0000000000..58c7deef00 --- /dev/null +++ b/engines/titanic/continue_save_dialog.h @@ -0,0 +1,105 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CONTINUE_SAVE_DIALOG_H +#define TITANIC_CONTINUE_SAVE_DIALOG_H + +#include "common/array.h" +#include "titanic/events.h" +#include "titanic/support/image.h" +#include "titanic/support/rect.h" +#include "titanic/support/string.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +#define EXIT_GAME -2 + +class CContinueSaveDialog : public CEventTarget { + struct SaveEntry { + int _slot; + CString _name; + SaveEntry() : _slot(0) {} + SaveEntry(int slot, const CString &name) : _slot(slot), _name(name) {} + }; +private: + Common::Array<SaveEntry> _saves; + CPetText _slotNames[5]; + int _highlightedSlot, _selectedSlot; + Point _mousePos; + bool _evilTwinShown; + bool _mouseDown; + int _restoreState, _startState; + Image _backdrop; + Image _evilTwin; + Image _restoreD, _restoreU, _restoreF; + Image _startD, _startU, _startF; +private: + /** + * Load the images + */ + void loadImages(); + + /** + * Render the dialog + */ + void render(); + + /** + * Render the buttons + */ + void renderButtons(); + + /** + * Render the slots + */ + void renderSlots(); + + /** + * Get the area to draw a slot name in + */ + Rect getSlotBounds(int index); +public: + CContinueSaveDialog(); + virtual ~CContinueSaveDialog(); + + virtual void mouseMove(const Point &mousePos); + virtual void leftButtonDown(const Point &mousePos); + virtual void leftButtonUp(const Point &mousePos); + virtual void rightButtonDown(const Point &mousePos); + virtual void rightButtonUp(const Point &mousePos); + virtual void keyDown(Common::KeyState keyState); + + /** + * Add a savegame to the list to be displayed + */ + void addSavegame(int slot, const CString &name); + + /** + * Show the dialog and wait for a slot to be selected + */ + int show(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CONTINUE_SAVE_DIALOG_H */ diff --git a/engines/titanic/core/background.cpp b/engines/titanic/core/background.cpp new file mode 100644 index 0000000000..733dfc1cf3 --- /dev/null +++ b/engines/titanic/core/background.cpp @@ -0,0 +1,78 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/background.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CBackground, CGameObject) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(SetFrameMsg) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + +CBackground::CBackground() : CGameObject(), _startFrame(0), _endFrame(0), _fieldDC(0) { +} + +void CBackground::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_startFrame, indent); + file->writeNumberLine(_endFrame, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_fieldDC, indent); + + CGameObject::save(file, indent); +} + +void CBackground::load(SimpleFile *file) { + file->readNumber(); + _startFrame = file->readNumber(); + _endFrame = file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + _fieldDC = file->readNumber(); + + CGameObject::load(file); +} + +bool CBackground::StatusChangeMsg(CStatusChangeMsg *msg) { + setVisible(true); + if (_fieldDC) { + playMovie(_startFrame, _endFrame, 16); + } else { + playMovie(_startFrame, _endFrame, 0); + } + return true; +} + +bool CBackground::SetFrameMsg(CSetFrameMsg *msg) { + loadFrame(msg->_frameNumber); + return true; +} + +bool CBackground::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/background.h b/engines/titanic/core/background.h new file mode 100644 index 0000000000..b7f160db28 --- /dev/null +++ b/engines/titanic/core/background.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BACKGROUND_H +#define TITANIC_BACKGROUND_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CBackground : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool SetFrameMsg(CSetFrameMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); +protected: + int _startFrame; + int _endFrame; + CString _string1; + CString _string2; + int _fieldDC; +public: + CLASSDEF; + CBackground(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BACKGROUND_H */ diff --git a/engines/titanic/core/click_responder.cpp b/engines/titanic/core/click_responder.cpp new file mode 100644 index 0000000000..f9694557df --- /dev/null +++ b/engines/titanic/core/click_responder.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/click_responder.h" + +namespace Titanic { + +void CClickResponder::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + + CGameObject::save(file, indent); +} + +void CClickResponder::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/click_responder.h b/engines/titanic/core/click_responder.h new file mode 100644 index 0000000000..78381b9948 --- /dev/null +++ b/engines/titanic/core/click_responder.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CLICK_RESPONDER_H +#define TITANIC_CLICK_RESPONDER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CClickResponder : public CGameObject { +protected: + CString _string1, _string2; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CLICK_RESPONDER_H */ diff --git a/engines/titanic/core/dont_save_file_item.cpp b/engines/titanic/core/dont_save_file_item.cpp new file mode 100644 index 0000000000..b8864bb2b5 --- /dev/null +++ b/engines/titanic/core/dont_save_file_item.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/dont_save_file_item.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CDontSaveFileItem, CFileItem); + +void CDontSaveFileItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); +} + +void CDontSaveFileItem::load(SimpleFile *file) { + file->readNumber(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/dont_save_file_item.h b/engines/titanic/core/dont_save_file_item.h new file mode 100644 index 0000000000..f5ec4f791d --- /dev/null +++ b/engines/titanic/core/dont_save_file_item.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DONT_SAVE_FILE_ITEM_H +#define TITANIC_DONT_SAVE_FILE_ITEM_H + +#include "titanic/core/file_item.h" + +namespace Titanic { + +class CDontSaveFileItem : public CFileItem { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DONT_SAVE_FILE_ITEM_H */ diff --git a/engines/titanic/core/drop_target.cpp b/engines/titanic/core/drop_target.cpp new file mode 100644 index 0000000000..05ea6445c3 --- /dev/null +++ b/engines/titanic/core/drop_target.cpp @@ -0,0 +1,72 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/drop_target.h" + +namespace Titanic { + +CDropTarget::CDropTarget() : CGameObject(), _fieldC4(0), + _fieldD4(0), _fieldE4(0), _fieldF4(0), _fieldF8(0), + _fieldFC(0), _field10C(1), _field110(8), _field114(20) { +} + +void CDropTarget::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writePoint(_pos1, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_fieldD4, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + file->writeQuotedLine(_string4, indent); + file->writeNumberLine(_field10C, indent); + file->writeNumberLine(_field110, indent); + file->writeNumberLine(_field114, indent); + + CGameObject::save(file, indent); +} + +void CDropTarget::load(SimpleFile *file) { + file->readNumber(); + _pos1 = file->readPoint(); + _fieldC4 = file->readNumber(); + _string1 = file->readString(); + _fieldD4 = file->readNumber(); + _string2 = file->readString(); + _fieldE4 = file->readNumber(); + _string3 = file->readString(); + _fieldF4 = file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + _string4 = file->readString(); + _field10C = file->readNumber(); + _field110 = file->readNumber(); + _field114 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/drop_target.h b/engines/titanic/core/drop_target.h new file mode 100644 index 0000000000..4bd0ae448c --- /dev/null +++ b/engines/titanic/core/drop_target.h @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DROP_TARGET_H +#define TITANIC_DROP_TARGET_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CDropTarget : public CGameObject { +private: + Point _pos1; + int _fieldC4; + CString _string1; + int _fieldD4; + CString _string2; + int _fieldE4; + CString _string3; + int _fieldF4; + int _fieldF8; + int _fieldFC; + CString _string4; + int _field10C; + int _field110; + int _field114; +public: + CLASSDEF; + CDropTarget(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DROP_TARGET_H */ diff --git a/engines/titanic/core/file_item.cpp b/engines/titanic/core/file_item.cpp new file mode 100644 index 0000000000..b783c758df --- /dev/null +++ b/engines/titanic/core/file_item.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/file_item.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CFileItem, CTreeItem); + +void CFileItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + CTreeItem::save(file, indent); +} + +void CFileItem::load(SimpleFile *file) { + file->readNumber(); + + CTreeItem::load(file); +} + +CString CFileItem::formFilename() const { + return ""; +} + +CString CFileItem::getFilename() const { + //dynamic_cast<CFileItem *>(getRoot())->formDataPath(); + return _filename; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/file_item.h b/engines/titanic/core/file_item.h new file mode 100644 index 0000000000..4cecee4882 --- /dev/null +++ b/engines/titanic/core/file_item.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FILE_ITEM_H +#define TITANIC_FILE_ITEM_H + +#include "titanic/support/string.h" +#include "titanic/core/list.h" +#include "titanic/core/tree_item.h" + +namespace Titanic { + +class CFileItem: public CTreeItem { + DECLARE_MESSAGE_MAP; +private: + CString _filename; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Returns true if the item is a file item + */ + virtual bool isFileItem() const { return true; } + + /** + * Form a filename for the file item + */ + CString formFilename() const; + + /** + * Get a string? + */ + CString getFilename() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FILE_ITEM_H */ diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp new file mode 100644 index 0000000000..723f2456f3 --- /dev/null +++ b/engines/titanic/core/game_object.cpp @@ -0,0 +1,1668 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/game_object.h" +#include "titanic/core/mail_man.h" +#include "titanic/core/resource_key.h" +#include "titanic/core/room_item.h" +#include "titanic/npcs/true_talk_npc.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/star_control/star_control.h" +#include "titanic/support/files_manager.h" +#include "titanic/support/screen_manager.h" +#include "titanic/support/video_surface.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CGameObject, CNamedItem); + +CCreditText *CGameObject::_credits; +int CGameObject::_soundHandles[4]; + +void CGameObject::init() { + _credits = nullptr; + _soundHandles[0] = _soundHandles[1] = 0; + _soundHandles[2] = _soundHandles[3] = -1; +} + +void CGameObject::deinit() { + if (_credits) { + _credits->clear(); + delete _credits; + _credits = nullptr; + } +} + +CGameObject::CGameObject(): CNamedItem() { + _bounds = Rect(0, 0, 15, 15); + _field34 = 0; + _field38 = 0; + _field3C = 0; + _field40 = 0; + _field44 = 0xF0; + _field48 = 0xF0; + _field4C = 0xFF; + _isMail = false; + _id = 0; + _roomFlags = 0; + _visible = true; + _field60 = 0; + _cursorId = CURSOR_ARROW; + _initialFrame = 0; + _frameNumber = -1; + _text = nullptr; + _textBorder = _textBorderRight = 0; + _field9C = 0; + _surface = nullptr; + _fieldB8 = 0; +} + +CGameObject::~CGameObject() { + delete _surface; + delete _text; +} + +void CGameObject::save(SimpleFile *file, int indent) { + file->writeNumberLine(7, indent); + _movieRangeInfoList.destroyContents(); + + if (_surface) { + const CMovieRangeInfoList *rangeList = _surface->getMovieRangeInfo(); + + if (rangeList) { + for (CMovieRangeInfoList::const_iterator i = rangeList->begin(); + i != rangeList->end(); ++i) { + CMovieRangeInfo *rangeInfo = new CMovieRangeInfo(*i); + rangeInfo->_initialFrame = (i == rangeList->begin()) ? getMovieFrame() : -1; + } + } + } + + _movieRangeInfoList.save(file, indent); + _movieRangeInfoList.destroyContents(); + + file->writeNumberLine(getMovieFrame(), indent + 1); + file->writeNumberLine(_cursorId, indent + 1); + _movieClips.save(file, indent + 1); + file->writeNumberLine(_field60, indent + 1); + file->writeNumberLine(_field40, indent + 1); + file->writeQuotedLine(_resource, indent + 1); + file->writeBounds(_bounds, indent + 1); + + file->writeFloatLine(_field34, indent + 1); + file->writeFloatLine(_field38, indent + 1); + file->writeFloatLine(_field3C, indent + 1); + + file->writeNumberLine(_field44, indent + 1); + file->writeNumberLine(_field48, indent + 1); + file->writeNumberLine(_field4C, indent + 1); + file->writeNumberLine(_fieldB8, indent + 1); + file->writeNumberLine(_visible, indent + 1); + file->writeNumberLine(_isMail, indent + 1); + file->writeNumberLine(_id, indent + 1); + file->writeNumberLine(_roomFlags, indent + 1); + + if (_surface) { + _surface->_resourceKey.save(file, indent); + } else { + CResourceKey resourceKey; + resourceKey.save(file, indent); + } + file->writeNumberLine(_surface != nullptr, indent); + + CNamedItem::save(file, indent); +} + +void CGameObject::load(SimpleFile *file) { + int val = file->readNumber(); + CResourceKey resourceKey; + + switch (val) { + case 7: + _movieRangeInfoList.load(file); + _frameNumber = file->readNumber(); + // Deliberate fall-through + + case 6: + _cursorId = (CursorId)file->readNumber(); + // Deliberate fall-through + + case 5: + _movieClips.load(file); + // Deliberate fall-through + + case 4: + _field60 = file->readNumber(); + // Deliberate fall-through + + case 3: + _field40 = file->readNumber(); + // Deliberate fall-through + + case 2: + _resource = file->readString(); + // Deliberate fall-through + + case 1: + _bounds = file->readBounds(); + _field34 = file->readFloat(); + _field38 = file->readFloat(); + _field3C = file->readFloat(); + _field44 = file->readNumber(); + _field48 = file->readNumber(); + _field4C = file->readNumber(); + _fieldB8 = file->readNumber(); + _visible = file->readNumber() != 0; + _isMail = file->readNumber(); + _id = file->readNumber(); + _roomFlags = file->readNumber(); + + resourceKey.load(file); + _surface = nullptr; + val = file->readNumber(); + if (val) { + _resource = resourceKey.getString(); + } + break; + + default: + break; + } + + CNamedItem::load(file); +} + +void CGameObject::draw(CScreenManager *screenManager) { + if (!_visible) + return; + if (_credits && _credits->_objectP == this) { + if (!_credits->draw()) + CGameObject::deinit(); + + return; + } + + if (_field40) { + // If a text object is defined, handle drawing it + if (_text && _bounds.intersects(getGameManager()->_bounds)) + _text->draw(screenManager); + + return; + } else { + if (!_surface) { + if (!_resource.empty()) { + loadResource(_resource); + _resource = ""; + } + } + + if (_surface) { + _bounds.setWidth(_surface->getWidth()); + _bounds.setHeight(_surface->getHeight()); + + if (!_bounds.width() || !_bounds.height()) + return; + + if (_frameNumber >= 0) { + loadFrame(_frameNumber); + _frameNumber = -1; + } + + if (!_movieRangeInfoList.empty()) + processMoveRangeInfo(); + + if (_bounds.intersects(getGameManager()->_bounds)) { + if (_surface) { + Point destPos(_bounds.left, _bounds.top); + screenManager->blitFrom(SURFACE_BACKBUFFER, _surface, &destPos); + } + + if (_text) + _text->draw(screenManager); + } + } + } +} + +Rect CGameObject::getBounds() const { + return (_surface && _surface->hasFrame()) ? _bounds : Rect(); +} + +void CGameObject::viewChange() { + // Handle freeing the surfaces of objects when their view is left + if (_surface) { + _resource = _surface->_resourceKey.getString(); + _initialFrame = getMovieFrame(); + + delete _surface; + _surface = nullptr; + } +} + +void CGameObject::stopMovie() { + if (_surface) + _surface->stopMovie(); +} + +bool CGameObject::checkPoint(const Point &pt, bool ignore40, bool visibleOnly) { + if ((!_visible && visibleOnly) || !_bounds.contains(pt)) + return false; + + if (ignore40 || _field40) + return true; + + if (!_surface) { + if (_frameNumber == -1) + return true; + loadFrame(_frameNumber); + if (!_surface) + return true; + } + + Common::Point pixelPos = pt - _bounds; + if (_surface->_transBlitFlag) { + pixelPos.y = ((_bounds.height() - _bounds.top) / 2) * 2 - pixelPos.y; + } + + uint transColor = _surface->getTransparencyColor(); + uint pixel = _surface->getPixel(pixelPos); + return pixel != transColor; +} + +bool CGameObject::clipRect(const Rect &rect1, Rect &rect2) const { + if (!rect2.intersects(rect1)) + return false; + + rect2.clip(rect1); + return true; +} + +void CGameObject::draw(CScreenManager *screenManager, const Rect &destRect, const Rect &srcRect) { + Rect tempRect = destRect; + if (clipRect(srcRect, tempRect)) { + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface) + screenManager->blitFrom(SURFACE_PRIMARY, &tempRect, _surface); + } +} + +void CGameObject::draw(CScreenManager *screenManager, const Point &destPos) { + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface) { + int xSize = _surface->getWidth(); + int ySize = _surface->getHeight(); + + if (xSize > 0 && ySize > 0) { + screenManager->blitFrom(SURFACE_BACKBUFFER, _surface, &destPos); + } + } +} + +void CGameObject::draw(CScreenManager *screenManager, const Point &destPos, const Rect &srcRect) { + draw(screenManager, Rect(destPos.x, destPos.y, destPos.x + 52, destPos.y + 52), srcRect); +} + +bool CGameObject::isPet() const { + return isInstanceOf(CPetControl::_type); +} + +void CGameObject::loadResource(const CString &name) { + switch (name.fileTypeSuffix()) { + case FILETYPE_IMAGE: + loadImage(name); + break; + case FILETYPE_MOVIE: + loadMovie(name); + break; + default: + break; + } +} + +void CGameObject::loadMovie(const CString &name, bool pendingFlag) { + g_vm->_filesManager->preload(name); + + // Create the surface if it doesn't already exist + if (!_surface) { + CGameManager *gameManager = getGameManager(); + _surface = new OSVideoSurface(gameManager->setScreenManager(), nullptr); + } + + // Load the new movie resource + CResourceKey key(name); + _surface->loadResource(key); + + if (_surface->hasSurface() && !pendingFlag) { + _bounds.setWidth(_surface->getWidth()); + _bounds.setHeight(_surface->getHeight()); + } + + if (_initialFrame) + loadFrame(_initialFrame); +} + +void CGameObject::loadImage(const CString &name, bool pendingFlag) { + // Get a refernce to the game and screen managers + CGameManager *gameManager = getGameManager(); + CScreenManager *screenManager; + + if (gameManager && (screenManager = CScreenManager::setCurrent()) != nullptr) { + // Destroy the object's surface if it already had one + if (_surface) { + delete _surface; + _surface = nullptr; + } + + g_vm->_filesManager->preload(name); + + if (!name.empty()) { + _surface = new OSVideoSurface(screenManager, CResourceKey(name), pendingFlag); + } + + if (_surface && !pendingFlag) { + _bounds.right = _surface->getWidth(); + _bounds.bottom = _surface->getHeight(); + } + + // Mark the object's area as dirty, so that on the next frame rendering + // this object will be redrawn + makeDirty(); + } + + _initialFrame = 0; +} + +void CGameObject::loadFrame(int frameNumber) { + if (frameNumber != -1 && !_resource.empty()) + loadResource(_resource); + + if (_surface) + _surface->setMovieFrame(frameNumber); + + makeDirty(); +} + +void CGameObject::processMoveRangeInfo() { + for (CMovieRangeInfoList::iterator i = _movieRangeInfoList.begin(); i != _movieRangeInfoList.end(); ++i) + (*i)->process(this); + + _movieRangeInfoList.destroyContents(); +} + +void CGameObject::makeDirty(const Rect &r) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + gameManager->extendBounds(r); +} + +void CGameObject::makeDirty() { + makeDirty(_bounds); +} + +bool CGameObject::isSoundActive(int handle) const { + if (handle != 0 && handle != -1) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + return gameManager->_sound.isActive(handle); + } + + return false; +} + +void CGameObject::playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated, int handleIndex) { + if (handleIndex < 0 || handleIndex > 3) + return; + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return; + + // Preload the file, and stop any existing sound using the given slot + CSound &sound = gameManager->_sound; + g_vm->_filesManager->preload(resName); + if (_soundHandles[handleIndex] != -1) { + sound.stopSound(_soundHandles[handleIndex]); + _soundHandles[handleIndex] = -1; + } + + // If no new name specified, then exit + if (resName.empty()) + return; + + uint newVolume = sound._soundManager.getModeVolume(mode); + uint volume = initialMute ? 0 : newVolume; + + CProximity prox; + prox._channelVolume = volume; + prox._repeated = repeated; + + switch (handleIndex) { + case 0: + prox._channel = 6; + break; + case 1: + prox._channel = 7; + break; + case 2: + prox._channel = 8; + break; + case 3: + prox._channel = 9; + break; + default: + break; + } + + _soundHandles[handleIndex] = sound.playSound(resName, prox); + + if (_soundHandles[handleIndex]) + sound.setVolume(_soundHandles[handleIndex], newVolume, 2); +} + +void CGameObject::setSoundVolume(int handle, uint percent, uint seconds) { + if (handle != 0 && handle != -1) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + return gameManager->_sound.setVolume(handle, percent, seconds); + } +} + +void CGameObject::stopGlobalSound(bool transition, int handleIndex) { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return; + CSound &sound = gameManager->_sound; + + if (handleIndex == -1) { + for (int idx = 0; idx < 4; ++idx) { + if (_soundHandles[idx] != -1) { + sound.setVolume(_soundHandles[idx], 0, transition ? 1 : 0); + sound.setCanFree(_soundHandles[idx]); + _soundHandles[idx] = -1; + } + } + } else if (handleIndex >= 0 && handleIndex <= 2 && _soundHandles[handleIndex] != -1) { + if (transition) { + // Transitioning to silent over 1 second + sound.setVolume(_soundHandles[handleIndex], 0, 1); + sleep(1000); + } + + sound.stopSound(_soundHandles[handleIndex]); + _soundHandles[handleIndex] = -1; + } + warning("CGameObject::soundFn4"); +} + +void CGameObject::setGlobalSoundVolume(int mode, uint seconds, int handleIndex) { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return; + CSound &sound = gameManager->_sound; + + if (handleIndex == -1) { + // Iterate through calling the method for each handle + for (int idx = 0; idx < 3; ++idx) + setGlobalSoundVolume(mode, seconds, idx); + } else if (handleIndex >= 0 && handleIndex <= 3 && _soundHandles[handleIndex] != -1) { + uint newVolume = sound._soundManager.getModeVolume(mode); + sound.setVolume(_soundHandles[handleIndex], newVolume, seconds); + } +} + +void CGameObject::sound8(bool flag) const { + getGameManager()->_sound.stopChannel(flag ? 3 : 0); +} + +void CGameObject::setVisible(bool val) { + if (val != _visible) { + _visible = val; + makeDirty(); + } +} + +void CGameObject::petHighlightGlyph(int val) { + CPetControl *pet = getPetControl(); + if (pet) + pet->highlightGlyph(val); +} + +void CGameObject::petHideCursor() { + CPetControl *pet = getPetControl(); + if (pet) + pet->hideCursor(); +} + +void CGameObject::petShowCursor() { + CPetControl *pet = getPetControl(); + if (pet) + pet->showCursor(); +} + +void CGameObject::petShow() { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + gameManager->_gameState._petActive = true; + gameManager->_gameState.setMode(GSMODE_INTERACTIVE); + gameManager->initBounds(); + } +} + +void CGameObject::petHide() { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + gameManager->_gameState._petActive = false; + gameManager->_gameState.setMode(GSMODE_INTERACTIVE); + gameManager->initBounds(); + } +} + +void CGameObject::petSetRemoteTarget() { + CPetControl *pet = getPetControl(); + if (pet) + pet->setRemoteTarget(this); +} + +void CGameObject::playMovie(uint flags) { + _frameNumber = -1; + + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + CGameObject *obj = (flags & MOVIE_NOTIFY_OBJECT) ? this : nullptr; + if (_surface) { + _surface->playMovie(flags, obj); + if (flags & MOVIE_GAMESTATE) + getGameManager()->_gameState.addMovie(_surface->_movie); + } +} + +void CGameObject::playMovie(int startFrame, int endFrame, uint flags) { + _frameNumber = -1; + + if (!_surface) { + if (!_resource.empty()) + loadResource(_resource); + _resource.clear(); + } + + CGameObject *obj = (flags & MOVIE_NOTIFY_OBJECT) ? this : nullptr; + if (_surface) { + _surface->playMovie(startFrame, endFrame, flags, obj); + if (flags & MOVIE_GAMESTATE) + getGameManager()->_gameState.addMovie(_surface->_movie); + } +} + + +void CGameObject::playMovie(int startFrame, int endFrame, int initialFrame, uint flags) { + _frameNumber = -1; + + if (!_surface) { + if (!_resource.empty()) + loadResource(_resource); + _resource.clear(); + } + + CGameObject *obj = (flags & MOVIE_NOTIFY_OBJECT) ? this : nullptr; + if (_surface) { + _surface->playMovie(startFrame, endFrame, initialFrame, flags, obj); + if (flags & MOVIE_GAMESTATE) + getGameManager()->_gameState.addMovie(_surface->_movie); + } +} + +void CGameObject::playClip(const CString &name, uint flags) { + _frameNumber = -1; + CMovieClip *clip = _movieClips.findByName(name); + if (clip) + playMovie(clip->_startFrame, clip->_endFrame, flags); +} + +void CGameObject::playClip(uint startFrame, uint endFrame) { + CMovieClip *clip = new CMovieClip("", startFrame, endFrame); + CGameManager *gameManager = getGameManager(); + CRoomItem *room = gameManager->getRoom(); + + gameManager->playClip(clip, room, room); +} + +void CGameObject::playRandomClip(const char **names, uint flags) { + // Count size of array + int count = 0; + for (const char **p = names; *p; ++p) + ++count; + + // Play clip + const char *name = names[g_vm->getRandomNumber(count - 1)]; + playClip(name, flags); +} + +void CGameObject::savePosition() { + _savedPos = _bounds; +} + +void CGameObject::resetPosition() { + setPosition(_savedPos); +} + +void CGameObject::setPosition(const Point &newPos) { + makeDirty(); + _bounds.moveTo(newPos); + makeDirty(); +} + +bool CGameObject::checkStartDragging(CMouseDragStartMsg *msg) { + if (_visible && checkPoint(msg->_mousePos, msg->_handled, 1)) { + savePosition(); + msg->_dragItem = this; + return true; + } else { + return false; + } +} + +bool CGameObject::hasActiveMovie() const { + if (_surface && _surface->_movie) + return _surface->_movie->isActive(); + return false; +} + +int CGameObject::getMovieFrame() const { + if (_surface && _surface->_movie) + return _surface->_movie->getFrame(); + return _initialFrame; +} + +bool CGameObject::surfaceHasFrame() const { + return _surface ? _surface->hasFrame() : false; +} + +void CGameObject::loadSound(const CString &name) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + g_vm->_filesManager->preload(name); + if (!name.empty()) + gameManager->_sound.loadSound(name); + } +} + +int CGameObject::playSound(const CString &name, uint volume, int val3, bool repeated) { + CProximity prox; + prox._channelVolume = volume; + prox._fieldC = val3; + prox._repeated = repeated; + return playSound(name, prox); +} + +int CGameObject::playSound(const CString &name, CProximity &prox) { + if (prox._positioningMode == POSMODE_VECTOR) { + // If the proximity doesn't have a position defined, default it to + // the position of the view to which the game object belongs + if (prox._posX == 0.0 && prox._posY == 0.0 && prox._posZ == 0.0) + findView()->getPosition(prox._posX, prox._posY, prox._posZ); + } + + CGameManager *gameManager = getGameManager(); + if (gameManager) { + g_vm->_filesManager->preload(name); + + gameManager->_sound.playSound(name, prox); + } + + return 0; +} + +int CGameObject::queueSound(const CString &name, uint priorHandle, uint volume, int val3, bool repeated) { + CProximity prox; + prox._fieldC = val3; + prox._repeated = repeated; + prox._channelVolume = volume; + prox._priorSoundHandle = priorHandle; + + return playSound(name, prox); +} + +void CGameObject::stopSound(int handle, uint seconds) { + if (handle != 0 && handle != -1) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + if (seconds) { + gameManager->_sound.setVolume(handle, 0, seconds); + gameManager->_sound.setCanFree(handle); + } else { + gameManager->_sound.stopSound(handle); + } + } + } +} + +int CGameObject::addTimer(int endVal, uint firstDuration, uint repeatDuration) { + CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(), + repeatDuration != 0, firstDuration, repeatDuration, this, endVal, CString()); + + getGameManager()->addTimer(timer); + return timer->_id; +} + +int CGameObject::addTimer(uint firstDuration, uint repeatDuration) { + CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(), + repeatDuration != 0, firstDuration, repeatDuration, this, 0, CString()); + + getGameManager()->addTimer(timer); + return timer->_id; +} + +int CGameObject::startAnimTimer(const CString &action, uint firstDuration, uint repeatDuration) { + CTimeEventInfo *timer = new CTimeEventInfo(g_vm->_events->getTicksCount(), + repeatDuration > 0, firstDuration, repeatDuration, this, 0, action); + getGameManager()->addTimer(timer); + + return timer->_id; +} + +void CGameObject::stopTimer(int id) { + getGameManager()->stopTimer(id); +} + +void CGameObject::gotoView(const CString &viewName, const CString &clipName) { + CViewItem *newView = parseView(viewName); + CGameManager *gameManager = getGameManager(); + CViewItem *oldView = gameManager ? gameManager->getView() : newView; + if (!oldView || !newView) + return; + + CMovieClip *clip = nullptr; + if (clipName.empty()) { + CLinkItem *link = oldView->findLink(newView); + if (link) + clip = link->getClip(); + } else { + clip = oldView->findNode()->findRoom()->findClip(clipName); + } + + // Change the view + gameManager->_gameState.changeView(newView, clip); +} + +CViewItem *CGameObject::parseView(const CString &viewString) { + int firstIndex = viewString.indexOf('.'); + int lastIndex = viewString.lastIndexOf('.'); + CString roomName, nodeName, viewName; + + if (firstIndex == -1) { + roomName = viewString; + } else { + roomName = viewString.left(firstIndex); + + if (lastIndex > firstIndex) { + nodeName = viewString.mid(firstIndex + 1, lastIndex - firstIndex - 1); + viewName = viewString.mid(lastIndex + 1); + } else { + nodeName = viewString.mid(firstIndex + 1); + } + } + + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return nullptr; + + CRoomItem *room = gameManager->getRoom(); + CProjectItem *project = room->getRoot(); + + // Ensure we have the specified room + if (project) { + if (room->getName() != roomName) { + // Scan for the correct room + for (room = project->findFirstRoom(); room && room->getName() != roomName; + room = project->findNextRoom(room)) ; + } + } + if (!room) + return nullptr; + + // Find the designated node within the room + CNodeItem *node = static_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); + while (node && node->getName() != nodeName) + node = static_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node)); + if (!node) + return nullptr; + + CViewItem *view = static_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); + while (view && view->getName() != viewName) + view = static_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view)); + if (!view) + return nullptr; + + // Find the view, so return it + return view; +} + +CString CGameObject::getViewFullName() const { + CGameManager *gameManager = getGameManager(); + CViewItem *view = gameManager->getView(); + CNodeItem *node = view->findNode(); + CRoomItem *room = node->findRoom(); + + return CString::format("%s.%s.%s", room->getName().c_str(), + node->getName().c_str(), view->getName().c_str()); +} + +void CGameObject::sleep(uint milli) { + g_vm->_events->sleep(milli); +} + +Point CGameObject::getMousePos() const { + return getGameManager()->_gameState.getMousePos(); +} + +bool CGameObject::compareViewNameTo(const CString &name) const { + return getViewFullName().compareToIgnoreCase(name); +} + +int CGameObject::compareRoomNameTo(const CString &name) { + CRoomItem *room = getGameManager()->getRoom(); + return room->getName().compareToIgnoreCase(name); +} + +CString CGameObject::getRoomName() const { + CRoomItem *room = getRoom(); + return room ? room->getName() : CString(); +} + +CString CGameObject::getRoomNodeName() const { + CNodeItem *node = getNode(); + if (!node) + return CString(); + + CRoomItem *room = node->findRoom(); + + return CString::format("%s.%s", room->getName().c_str(), node->getName().c_str()); +} + +CString CGameObject::getFullViewName() { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->getFullViewName() : CString(); +} + +CGameObject *CGameObject::getMailManFirstObject() const { + CMailMan *mailMan = getMailMan(); + return mailMan ? mailMan->getFirstObject() : nullptr; +} + +CGameObject *CGameObject::getMailManNextObject(CGameObject *prior) const { + CMailMan *mailMan = getMailMan(); + return mailMan ? mailMan->getNextObject(prior) : nullptr; +} + +CGameObject *CGameObject::findMailByFlags(int mode, uint roomFlags) { + CMailMan *mailMan = getMailMan(); + if (!mailMan) + return nullptr; + + for (CGameObject *obj = mailMan->getFirstObject(); obj; + obj = mailMan->getNextObject(obj)) { + if (compareRoomFlags(mode, roomFlags, obj->_roomFlags)) + return obj; + } + + return nullptr; +} + +CGameObject *CGameObject::getNextMail(CGameObject *prior) { + CMailMan *mailMan = getMailMan(); + return mailMan ? mailMan->getNextObject(prior) : nullptr; +} + +CGameObject *CGameObject::findRoomObject(const CString &name) const { + return static_cast<CGameObject *>(findRoom()->findByName(name)); +} + +CGameObject *CGameObject::findInRoom(const CString &name) { + CRoomItem *room = getRoom(); + return room ? static_cast<CGameObject *>(room->findByName(name)) : nullptr; +} + +Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) { + CGameObject *go; + *item = nullptr; + + // Scan under PET if flagged + if (findAreas & FIND_PET) { + for (go = getPetControl()->getFirstObject(); go; go = getPetControl()->getNextObject(go)) { + if (go->getName() == name) { + *item = go; + return FOUND_PET; + } + } + } + + if (findAreas & FIND_MAILMAN) { + for (go = getMailManFirstObject(); go; go = getMailManNextObject(go)) { + if (go->getName() == name) { + *item = go; + return FOUND_MAILMAN; + } + } + } + + if (findAreas & FIND_GLOBAL) { + go = static_cast<CGameObject *>(getRoot()->findByName(name)); + if (go) { + *item = go; + return FOUND_GLOBAL; + } + } + + if (findAreas & FIND_ROOM) { + go = findRoomObject(name); + if (go) { + *item = go; + return FOUND_ROOM; + } + } + + return FOUND_NONE; +} + +void CGameObject::moveToView() { + CViewItem *view = getGameManager()->getView(); + detach(); + view->addUnder(this); +} + +void CGameObject::moveToView(const CString &name) { + CViewItem *view = parseView(name); + detach(); + view->addUnder(this); +} + +void CGameObject::stateInc14() { + getGameManager()->_gameState.inc14(); +} + +int CGameObject::stateGet14() const { + return getGameManager()->_gameState._field14; +} + +void CGameObject::stateSet24() { + getGameManager()->_gameState.set24(1); +} + +int CGameObject::stateGet24() const { + return getGameManager()->_gameState.get24(); +} + +void CGameObject::stateInc38() { + getGameManager()->_gameState.inc38(); +} + +int CGameObject::stateGet38() const { + return getGameManager()->_gameState._field38; +} + +void CGameObject::quitGame() { + getGameManager()->_gameState._quitGame = true; +} + +void CGameObject::inc54() { + getGameManager()->inc54(); +} + +void CGameObject::dec54() { + getGameManager()->dec54(); +} + +void CGameObject::setMovieFrameRate(double rate) { + if (_surface) + _surface->setMovieFrameRate(rate); +} + +void CGameObject::setTextBorder(const CString &str, int border, int borderRight) { + if (!_text) + _text = new CPetText(); + _textBorder = border; + _textBorderRight = borderRight; + + _text->setText(str); + CScreenManager *screenManager = getGameManager()->setScreenManager(); + _text->scrollToTop(screenManager); +} + +void CGameObject::setTextHasBorders(bool hasBorders) { + if (!_text) + _text = new CPetText(); + + _text->setHasBorder(hasBorders); +} + +void CGameObject::setTextBounds() { + Rect rect = _bounds; + rect.grow(_textBorder); + rect.right -= _textBorderRight; + + _text->setBounds(rect); + makeDirty(); +} + +void CGameObject::setTextColor(byte r, byte g, byte b) { + if (!_text) + _text = new CPetText(); + + _text->setColor(r, g, b); +} + +void CGameObject::setTextFontNumber(int fontNumber) { + if (!_text) + _text = new CPetText(); + + _text->setFontNumber(fontNumber); +} + +int CGameObject::getTextWidth() const { + assert(_text); + return _text->getTextWidth(CScreenManager::_screenManagerPtr); +} + +CTextCursor *CGameObject::getTextCursor() const { + return CScreenManager::_screenManagerPtr->_textCursor; +} + +void CGameObject::scrollTextUp() { + if (_text) + _text->scrollUp(CScreenManager::_screenManagerPtr); +} + +void CGameObject::scrollTextDown() { + if (_text) + _text->scrollDown(CScreenManager::_screenManagerPtr); +} + +void CGameObject::lockMouse() { + CGameManager *gameMan = getGameManager(); + gameMan->lockInputHandler(); + + if (CScreenManager::_screenManagerPtr->_mouseCursor) + CScreenManager::_screenManagerPtr->_mouseCursor->hide(); +} + +void CGameObject::hideMouse() { + CScreenManager::_screenManagerPtr->_mouseCursor->hide(); +} + +void CGameObject::showMouse() { + CScreenManager::_screenManagerPtr->_mouseCursor->show(); +} + +void CGameObject::disableMouse() { + lockInputHandler(); + hideMouse(); +} + +void CGameObject::enableMouse() { + unlockInputHandler(); + showMouse(); +} + +void CGameObject::mouseLockE4() { + CScreenManager::_screenManagerPtr->_mouseCursor->lockE4(); +} + +void CGameObject::mouseUnlockE4() { + CScreenManager::_screenManagerPtr->_mouseCursor->unlockE4(); +} + +void CGameObject::mouseSaveState(int v1, int v2, int v3) { + CScreenManager::_screenManagerPtr->_mouseCursor->saveState(v1, v2, v3); +} + +void CGameObject::lockInputHandler() { + getGameManager()->lockInputHandler(); +} + +void CGameObject::unlockInputHandler() { + getGameManager()->unlockInputHandler(); +} + +void CGameObject::unlockMouse() { + if (CScreenManager::_screenManagerPtr->_mouseCursor) + CScreenManager::_screenManagerPtr->_mouseCursor->show(); + + CGameManager *gameMan = getGameManager(); + gameMan->unlockInputHandler(); +} + +void CGameObject::loadSurface() { + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface) + _surface->loadIfReady(); +} + +bool CGameObject::changeView(const CString &viewName) { + return changeView(viewName, ""); +} + +bool CGameObject::changeView(const CString &viewName, const CString &clipName) { + CViewItem *newView = parseView(viewName); + CGameManager *gameManager = getGameManager(); + CViewItem *oldView = gameManager->getView(); + + if (!oldView || !newView) + return false; + + CMovieClip *clip = nullptr; + if (!clipName.empty()) { + clip = oldView->findNode()->findRoom()->findClip(clipName); + } else { + CLinkItem *link = oldView->findLink(newView); + if (link) + clip = link->getClip(); + } + + gameManager->_gameState.changeView(newView, clip); + return true; +} + +void CGameObject::dragMove(const Point &pt) { + if (_surface) { + _bounds.setWidth(_surface->getWidth()); + _bounds.setHeight(_surface->getHeight()); + } + + setPosition(Point(pt.x - _bounds.width() / 2, pt.y - _bounds.height() / 2)); +} + +bool CGameObject::isObjectDragging() const { + CTreeItem *item = getGameManager()->_dragItem; + return item ? static_cast<CGameObject *>(item) != nullptr : false; +} + +Point CGameObject::getControid() const { + return Point(_bounds.left + _bounds.width() / 2, + _bounds.top + _bounds.height() / 2); +} + +bool CGameObject::clipExistsByStart(const CString &name, int startFrame) const { + return _movieClips.existsByStart(name, startFrame); +} + +bool CGameObject::clipExistsByEnd(const CString &name, int endFrame) const { + return _movieClips.existsByEnd(name, endFrame); +} + +void CGameObject::petClear() const { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->resetActiveNPC(); +} + +CDontSaveFileItem *CGameObject::getDontSave() const { + CProjectItem *project = getRoot(); + return project ? project->getDontSaveFileItem() : nullptr; +} + +CPetControl *CGameObject::getPetControl() const { + return static_cast<CPetControl *>(getDontSaveChild(CPetControl::_type)); +} + +CMailMan *CGameObject::getMailMan() const { + return dynamic_cast<CMailMan *>(getDontSaveChild(CMailMan::_type)); +} + +CTreeItem *CGameObject::getDontSaveChild(ClassDef *classDef) const { + CProjectItem *root = getRoot(); + if (!root) + return nullptr; + + CDontSaveFileItem *dontSave = root->getDontSaveFileItem(); + if (!dontSave) + return nullptr; + + return dontSave->findChildInstanceOf(classDef); +} + +CRoomItem *CGameObject::getHiddenRoom() const { + CProjectItem *root = getRoot(); + return root ? root->findHiddenRoom() : nullptr; +} + +CRoomItem *CGameObject::locateRoom(const CString &name) const { + if (name.empty()) + return nullptr; + + CProjectItem *project = getRoot(); + for (CRoomItem *room = project->findFirstRoom(); room; room = project->findNextRoom(room)) { + if (!room->getName().compareToIgnoreCase(name)) + return room; + } + + return nullptr; +} + +CGameObject *CGameObject::getHiddenObject(const CString &name) const { + CRoomItem *room = getHiddenRoom(); + return room ? static_cast<CGameObject *>(findUnder(room, name)) : nullptr; +} + +CTreeItem *CGameObject::findUnder(CTreeItem *parent, const CString &name) const { + if (!parent) + return nullptr; + + for (CTreeItem *item = parent->getFirstChild(); item; item = item->scan(parent)) { + if (item->getName() == name) + return item; + } + + return nullptr; +} + +CRoomItem *CGameObject::findRoomByName(const CString &name) { + CProjectItem *project = getRoot(); + for (CRoomItem *room = project->findFirstRoom(); room; room = project->findNextRoom(room)) { + if (!room->getName().compareToIgnoreCase(name)) + return room; + } + + return nullptr; +} + +CMusicRoom *CGameObject::getMusicRoom() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? &gameManager->_musicRoom : nullptr; +} + +int CGameObject::getPassengerClass() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->_gameState._passengerClass : 3; +} + +int CGameObject::getPriorClass() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->_gameState._priorClass : 3; +} + +void CGameObject::setPassengerClass(int newClass) { + if (newClass >= 1 && newClass <= 4) { + // Change the passenger class + CGameManager *gameMan = getGameManager(); + gameMan->_gameState._priorClass = gameMan->_gameState._passengerClass; + gameMan->_gameState._passengerClass = newClass; + + // Setup the PET again, so the new class's PET background can take effect + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->setup(); + } +} + +void CGameObject::createCredits() { + _credits = new CCreditText(); + CScreenManager *screenManager = getGameManager()->setScreenManager(); + _credits->load(this, screenManager, _bounds); +} + +void CGameObject::fn10(int v1, int v2, int v3) { + makeDirty(); + _field44 = v1; + _field48 = v2; + _field4C = v3; +} + +void CGameObject::movieSetAudioTiming(bool flag) { + if (!_surface && !_resource.empty()) { + loadResource(_resource); + _resource.clear(); + } + + if (_surface && _surface->_movie) + _surface->_movie->_hasAudioTiming = flag; +} + +void CGameObject::movieEvent(int frameNumber) { + if (_surface) + _surface->addMovieEvent(frameNumber, this); +} + +void CGameObject::movieEvent() { + if (_surface) + _surface->addMovieEvent(-1, this); +} + +int CGameObject::getClipDuration(const CString &name, int frameRate) const { + CMovieClip *clip = _movieClips.findByName(name); + return clip ? (clip->_endFrame - clip->_startFrame) * 1000 / frameRate : 0; +} + +uint32 CGameObject::getTickCount() { + return g_vm->_events->getTicksCount(); +} + +bool CGameObject::compareRoomFlags(int mode, uint flags1, uint flags2) { + switch (mode) { + case 1: + return CRoomFlags::compareLocation(flags1, flags2); + + case 2: + return CRoomFlags::compareClassElevator(flags1, flags2); + + case 3: + return CRoomFlags::isTitania(flags1, flags2); + + default: + return false; + } +} + +void CGameObject::setState1C(bool flag) { + getGameManager()->_gameState._field1C = flag; +} + +void CGameObject::addMail(int mailId) { + CMailMan *mailMan = getMailMan(); + if (mailMan) { + makeDirty(); + mailMan->addMail(this, mailId); + } +} + +void CGameObject::setMailId(int mailId) { + CMailMan *mailMan = getMailMan(); + if (mailMan) { + makeDirty(); + mailMan->setMailId(this, mailId); + } +} + +bool CGameObject::mailExists(int id) const { + return findMail(id) != nullptr; +} + +CGameObject *CGameObject::findMail(int id) const { + CMailMan *mailMan = getMailMan(); + return mailMan ? mailMan->findMail(id) : nullptr; +} + +void CGameObject::removeMail(int id, int v) { + CMailMan *mailMan = getMailMan(); + if (mailMan) + mailMan->removeMail(id, v); +} + +void CGameObject::resetMail() { + CMailMan *mailMan = getMailMan(); + if (mailMan) + mailMan->resetValue(); +} + +int CGameObject::getNewRandomNumber(int max, int *oldVal) { + if (oldVal) { + int startingVal = *oldVal; + while (*oldVal == startingVal && max > 0) + *oldVal = g_vm->getRandomNumber(max); + + return *oldVal; + } else { + return g_vm->getRandomNumber(max); + } +} + +/*------------------------------------------------------------------------*/ + +CRoomItem *CGameObject::getRoom() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->getRoom() : nullptr; +} + +CNodeItem *CGameObject::getNode() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->getNode() : nullptr; +} + +CViewItem *CGameObject::getView() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->getView() : nullptr; +} + +/*------------------------------------------------------------------------*/ + +void CGameObject::petAddToCarryParcel(CGameObject *obj) { + CPetControl *pet = getPetControl(); + if (pet) { + CGameObject *parcel = pet->getHiddenObject("CarryParcel"); + if (parcel) + parcel->moveUnder(obj); + } +} + +void CGameObject::petAddToInventory() { + CPetControl *pet = getPetControl(); + if (pet) { + makeDirty(); + pet->addToInventory(this); + } +} + +CTreeItem *CGameObject::petContainerRemove(CGameObject *obj) { + CPetControl *pet = getPetControl(); + if (!obj || !pet) + return nullptr; + if (!obj->compareRoomNameTo("CarryParcel")) + return obj; + + CGameObject *item = static_cast<CGameObject *>(pet->getLastChild()); + if (item) + item->detach(); + + pet->moveToHiddenRoom(obj); + pet->removeFromInventory(item, false, false); + + return item; +} + +bool CGameObject::petCheckNode(const CString &name) { + CPetControl *pet = getPetControl(); + return pet ? pet->checkNode(name) : false; +} + +bool CGameObject::petDismissBot(const CString &name) { + CPetControl *pet = getPetControl(); + return pet ? pet->dismissBot(name) : false; +} + +bool CGameObject::petDoorOrBellbotPresent() const { + CPetControl *pet = getPetControl(); + return pet ? pet->isDoorOrBellbotPresent() : false; +} + +void CGameObject::petDisplayMessage(int unused, const CString &msg) { + petDisplayMessage(msg); +} + +void CGameObject::petDisplayMessage(const CString &msg) { + CPetControl *pet = getPetControl(); + if (pet) + pet->displayMessage(msg); +} + +void CGameObject::petInvChange() { + CPetControl *pet = getPetControl(); + if (pet) + pet->invChange(this); +} + +void CGameObject::petLockInput() { + getPetControl()->incInputLocks(); +} + +void CGameObject::petMoveToHiddenRoom() { + CPetControl *pet = getPetControl(); + if (pet) { + makeDirty(); + pet->moveToHiddenRoom(this); + } +} + +void CGameObject::petReassignRoom(int passClassNum) { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->reassignRoom(passClassNum); +} + +void CGameObject::petSetArea(PetArea newArea) const { + CPetControl *pet = getPetControl(); + if (pet) + pet->setArea(newArea); +} + +void CGameObject::petSetRoomsWellEntry(int entryNum) { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->setRoomsWellEntry(entryNum); +} + +int CGameObject::petGetRoomsWellEntry() const { + CPetControl *petControl = getPetControl(); + return petControl ? petControl->getRoomsWellEntry() : 0; +} + +void CGameObject::petSetRooms1D4(int v) { + CPetControl *pet = getPetControl(); + if (pet) + pet->setRooms1D4(v); +} + +void CGameObject::petOnSummonBot(const CString &name, int val) { + CPetControl *pet = getPetControl(); + if (pet) + pet->summonBot(name, val); +} + +void CGameObject::petUnlockInput() { + getPetControl()->decInputLocks(); +} + +/*------------------------------------------------------------------------*/ + +CStarControl *CGameObject::getStarControl() const { + CStarControl *starControl = static_cast<CStarControl *>(getDontSaveChild(CStarControl::_type)); + if (!starControl) { + CViewItem *view = getGameManager()->getView(); + if (view) + starControl = static_cast<CStarControl *>(view->findChildInstanceOf(CStarControl::_type)); + } + + return starControl; +} + +void CGameObject::starFn1(int v) { + CStarControl *starControl = getStarControl(); + if (starControl) + starControl->fn1(v); +} + +void CGameObject::starFn2() { + CStarControl *starControl = getStarControl(); + if (starControl) + starControl->fn4(); +} + +/*------------------------------------------------------------------------*/ + +void CGameObject::startTalking(const CString &npcName, uint id, CViewItem *view) { + CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(npcName)); + startTalking(npc, id, view); +} + +void CGameObject::startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + CTrueTalkManager *talkManager = gameManager->getTalkManager(); + if (talkManager) + talkManager->start(npc, id, view); + } +} + +void CGameObject::endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view) { + CPetControl *pet = getPetControl(); + if (pet) + pet->setActiveNPC(npc); + + if (viewFlag) + npc->setView(view); + + if (pet) + pet->refreshNPC(); +} + +void CGameObject::talkSetDialRegion(const CString &name, int dialNum, int regionNum) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + CTrueTalkManager *talkManager = gameManager->getTalkManager(); + if (talkManager) { + TTnpcScript *npcScript = talkManager->getTalker(name); + if (npcScript) + npcScript->setDialRegion(dialNum, regionNum); + } + } +} + +int CGameObject::talkGetDialRegion(const CString &name, int dialNum) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + CTrueTalkManager *talkManager = gameManager->getTalkManager(); + if (talkManager) { + TTnpcScript *npcScript = talkManager->getTalker(name); + if (npcScript) + return npcScript->getDialRegion(dialNum); + } + } + + return 0; +} + +/*------------------------------------------------------------------------*/ + +uint CGameObject::getNodeChangedCtr() const { + return getGameManager()->_gameState.getNodeChangedCtr(); +} + +uint CGameObject::getNodeEnterTicks() const { + return getGameManager()->_gameState.getNodeEnterTicks(); +} + + +} // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h new file mode 100644 index 0000000000..2dc539f739 --- /dev/null +++ b/engines/titanic/core/game_object.h @@ -0,0 +1,947 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GAME_OBJECT_H +#define TITANIC_GAME_OBJECT_H + +#include "titanic/support/mouse_cursor.h" +#include "titanic/support/credit_text.h" +#include "titanic/support/movie_range_info.h" +#include "titanic/sound/proximity.h" +#include "titanic/support/rect.h" +#include "titanic/support/movie_clip.h" +#include "titanic/core/named_item.h" +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +enum Find { FIND_GLOBAL = 1, FIND_ROOM = 2, FIND_PET = 4, FIND_MAILMAN = 8 }; +enum Found { FOUND_NONE = 0, FOUND_GLOBAL = 1, FOUND_ROOM = 2, FOUND_PET = 3, FOUND_MAILMAN = 4 }; + +class CDontSaveFileItem; +class CMailMan; +class CMusicRoom; +class CRoomItem; +class CStarControl; +class CMouseDragStartMsg; +class CTrueTalkNPC; +class CVideoSurface; +class OSMovie; + +class CGameObject : public CNamedItem { + friend class OSMovie; + DECLARE_MESSAGE_MAP; +private: + static CCreditText *_credits; + static int _soundHandles[4]; +private: + /** + * Load a visual resource for the object + */ + void loadResource(const CString &name); + + /** + * Loads a movie + */ + void loadMovie(const CString &name, bool pendingFlag = true); + + /** + * Loads an image + */ + void loadImage(const CString &name, bool pendingFlag = true); + + /** + * Process and remove any registered movie range info + */ + void processMoveRangeInfo(); + + /** + * Merges one rect into another, and returns true if there was + * a common intersection + */ + bool clipRect(const Rect &rect1, Rect &rect2) const; +protected: + Rect _bounds; + double _field34; + double _field38; + double _field3C; + int _field40; + int _field44; + int _field48; + int _field4C; + CMovieClipList _movieClips; + int _initialFrame; + CMovieRangeInfoList _movieRangeInfoList; + int _frameNumber; + CPetText *_text; + uint _textBorder; + uint _textBorderRight; + int _field9C; + Common::Point _savedPos; + CVideoSurface *_surface; + CString _resource; + int _fieldB8; +protected: + /** + * Saves the current position the object is located at + */ + void savePosition(); + + /** + * Resets the object back to the previously saved starting position + */ + void resetPosition(); + + /** + * Check for starting to drag the object + */ + bool checkStartDragging(CMouseDragStartMsg *msg); + + /** + * Goto a new view + */ + void gotoView(const CString &viewName, const CString &clipName); + + /** + * Parses a view into it's components of room, node, and view, + * and locates the designated view + */ + CViewItem * parseView(const CString &viewString); + + void inc54(); + void dec54(); + + /** + * Locks/hides the mouse + */ + void lockMouse(); + + /** + * Unlocks/shows the mouse + */ + void unlockMouse(); + + /** + * Hides the mouse cursor + */ + void hideMouse(); + + /** + * Shows the mouse cursor + */ + void showMouse(); + + /** + * Disable the mouse + */ + void disableMouse(); + + /** + * Enable the mouse + */ + void enableMouse(); + + void mouseLockE4(); + void mouseUnlockE4(); + + void mouseSaveState(int v1, int v2, int v3); + + /** + * Lock the input handler + */ + void lockInputHandler(); + + /** + * Unlock the input handler + */ + void unlockInputHandler(); + + /** + * Load a sound + */ + void loadSound(const CString &name); + + /** + * Plays a sound + * @param resName Filename of sound to play + * @param volume Volume level + */ + int playSound(const CString &name, uint volume = 100, int val3 = 0, bool repeated = false); + + /** + * Plays a sound + * @param resName Filename of sound to play + * @param prox Proximity object with the sound data + */ + int playSound(const CString &name, CProximity &prox); + + /** + * Queues a sound to play after a specified one finishes + * @param resName Filename of sound to play + * @param volume Volume level + */ + int queueSound(const CString &name, uint priorHandle, uint volume = 100, int val3 = 0, bool repeated = false); + + /** + * Stop a sound + * @param handle Sound handle + * @param seconds Optional number of seconds to transition sound off + */ + void stopSound(int handle, uint seconds = 0); + + /** + * Returns true if a sound with the specified handle is active + */ + bool isSoundActive(int handle) const; + + /** + * Sets the volume for a sound + * @param handle Sound handle + * @param volume Volume percentage (0 to 100) + * @param seconds Number of seconds to transition to the new volume + */ + void setSoundVolume(int handle, uint percent, uint seconds); + + /** + * Plays a sound, and saves it's handle in the global sound handles list + * @param resName Filename of sound to play + * @param mode Volume mode level + * @param initialMute If set, sound transitions in from mute over 2 seconds + * @param repeated Flag for repeating sounds + * @param handleIndex Slot 0 to 3 in the shared sound handle list to store the sound's handle + */ + void playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated, int handleIndex); + + /** + * Stops a sound saved in the global sound handle list + * @param transition If set, the sound transitions to silent before stopping + * @param handleIndex Index of sound to stop. If -1, all global sounds are stopped + */ + void stopGlobalSound(bool transition, int handleIndex); + + /** + * Updates the volume for a global sound based on the specified mode's volume + * @param mode Volume level mode + * @param seconds Number of seconds to transition to new volume + * @param handleIndex Index of global sound to update. If -1, all global sounds are updated + */ + void setGlobalSoundVolume(int mode, uint seconds, int handleIndex); + + void sound8(bool flag) const; + + /** + * Adds a timer + */ + int addTimer(int endVal, uint firstDuration, uint repeatDuration); + + /** + * Adds a timer + */ + int addTimer(uint firstDuration, uint repeatDuration = 0); + + /** + * Start an animation timer + */ + int startAnimTimer(const CString &action, uint firstDuration, uint repeatDuration = 0); + + /** + * Stops a timer + */ + void stopTimer(int id); + + /** + * Causes the game to sleep for the specified time + */ + void sleep(uint milli); + + /** + * Get the current mouse cursor position + */ + Point getMousePos() const; + + /* + * Compares the current view's name in a Room.Node.View tuplet + * string form to the passed string + */ + bool compareViewNameTo(const CString &name) const; + + /** + * Compare the name of the parent room to the item to a passed string + */ + int compareRoomNameTo(const CString &name); + + /** + * Gets the first object under the system MailMan + */ + CGameObject *getMailManFirstObject() const; + + /** + * Gets the next object under the system MailMan + */ + CGameObject *getMailManNextObject(CGameObject *prior) const; + + /** + * Find mail by room flags + */ + CGameObject *findMailByFlags(int mode, uint roomFlags); + + /** + * Find next mail from a given prior one + */ + CGameObject *getNextMail(CGameObject *prior); + + /** + * Finds an object by name within the object's room + */ + CGameObject *findRoomObject(const CString &name) const; + + /** + * FInds an object under the current room + */ + CGameObject *findInRoom(const CString &name); + + /** + * Moves the object to be under the current view + */ + void moveToView(); + + /** + * Moves the object to be under the specified view + */ + void moveToView(const CString &name); + + /** + * Change the view + */ + bool changeView(const CString &viewName, const CString &clipName); + + /** + * Change the view + */ + bool changeView(const CString &viewName); + + /** + * Get the centre of the game object's bounds + */ + Point getControid() const; + + /** + * Play an arbitrary clip + */ + void playClip(const CString &name, uint flags); + + /** + * Play a clip + */ + void playClip(uint startFrame, uint endFrame); + + /** + * Play a clip randomly from a passed list of names + */ + void playRandomClip(const char **names, uint flags); + + /** + * Return the current view/node/room as a single string + */ + CString getViewFullName() const; + + /** + * Returns true if a clip exists in the list with a given name + * and starting frame number + */ + bool clipExistsByStart(const CString &name, int startFrame = 0) const; + + /** + * Returns true if a clip exists in the list with a given name + * and ending frame number + */ + bool clipExistsByEnd(const CString &name, int endFrame = 0) const; + + /** + * Clear the PET display + */ + void petClear() const; + + /** + * Returns the MailMan + */ + CMailMan *getMailMan() const; + + /** + * Gets the don't save container object + */ + CDontSaveFileItem *getDontSave() const; + + /** + * Returns a child of the Dont Save area of the project of the given class + */ + CTreeItem *getDontSaveChild(ClassDef *classDef) const; + + /** + * Returns the special hidden room container + */ + CRoomItem *getHiddenRoom() const; + + /** + * Locates a room with the given name + */ + CRoomItem *locateRoom(const CString &name) const; + + /** + * Scan the specified room for an item by name + */ + CTreeItem *findUnder(CTreeItem *parent, const CString &name) const; + + /** + * Finds a room by name + */ + CRoomItem *findRoomByName(const CString &name); + + /** + * Returns the music room instance from the game manager + */ + CMusicRoom *getMusicRoom() const; + + /** + * Set's the player's passenger class + */ + void setPassengerClass(int newClass); + + /** + * Overrides whether the object's movie has audio timing + */ + void movieSetAudioTiming(bool flag); + + void fn10(int v1, int v2, int v3); + + /** + * Gets the duration of a specified clip in milliseconds + */ + int getClipDuration(const CString &name, int frameRate = 14) const; + + /** + * Returns the current system tick count + */ + uint32 getTickCount(); + + /** + * Adds an object to the mail list + */ + void addMail(int mailId); + + /** + * Sets the mail identifier for an object + */ + void setMailId(int mailId); + + /** + * Returns true if a mail with a specified Id exists + */ + bool mailExists(int id) const; + + /** + * Returns a specified mail, if one exists + */ + CGameObject *findMail(int id) const; + + /** + * Remove an object from the mail list + */ + void removeMail(int id, int v); + + /** + * Resets the Mail Man value + */ + void resetMail(); + + /** + * Locks the PET, disabling all input. Can be called multiple times + */ + void petLockInput(); + + /** + * Unlocks PET input + */ + void petUnlockInput(); + + /** + * Flag to quit the game + */ + void quitGame(); + + /** + * Set the frame rate for the currently loaded movie + */ + void setMovieFrameRate(double rate); + + /** + * Set up the text borders for the object + */ + void setTextBorder(const CString &str, int border = 0, int borderRight = 0); + + /** + * Sets whether the text will use borders + */ + void setTextHasBorders(bool hasBorders); + + /** + * Sets the bounds for a previously defined text area + */ + void setTextBounds(); + + /** + * Sets the color for the object's text + */ + void setTextColor(byte r, byte g, byte b); + + /** + * Sets the font number to use for text + */ + void setTextFontNumber(int fontNumber); + + /** + * Gets the width of the text contents + */ + int getTextWidth() const; + + /** + * Returns the text cursor + */ + CTextCursor *getTextCursor() const; + + /** + * Scroll text up + */ + void scrollTextUp(); + + /** + * Scroll text down + */ + void scrollTextDown(); + + /** + * Gets a new random number + */ + int getNewRandomNumber(int max, int *oldVal = nullptr); +public: + bool _isMail; + int _id; + uint _roomFlags; + int _field60; + CursorId _cursorId; + bool _visible; +public: + /** + * Initializes statics + */ + static void init(); + + /** + * Deinitializes statics + */ + static void deinit(); +public: + CLASSDEF; + CGameObject(); + ~CGameObject(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Returns the clip list, if any, associated with the item + */ + virtual const CMovieClipList *getMovieClips() const { return &_movieClips; } + + /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Gets the bounds occupied by the item + */ + virtual Rect getBounds() const; + + /** + * Called when the view changes + */ + virtual void viewChange(); + + /** + * Allows the item to draw itself + */ + void draw(CScreenManager *screenManager, const Rect &destRect, const Rect &srcRect); + + /** + * Allows the item to draw itself + */ + void draw(CScreenManager *screenManager, const Point &destPos); + + /** + * Allows the item to draw itself + */ + void draw(CScreenManager *screenManager, const Point &destPos, const Rect &srcRect); + + /** + * Returns true if the item is the PET control + */ + virtual bool isPet() const; + + /** + * Checks the passed point is validly in the object, + * with extra checking of object flags status + */ + bool checkPoint(const Point &pt, bool ignore40 = false, bool visibleOnly = false); + + /** + * Set the position of the object + */ + void setPosition(const Point &newPos); + + /** + * Change the object's status + */ + void playMovie(uint flags); + + /** + * Play the movie specified in _resource + */ + void playMovie(int startFrame, int endFrame, uint flags); + + /** + * Play the movie specified in _resource + */ + void playMovie(int startFrame, int endFrame, int initialFrame, uint flags); + + /** + * Returns true if the object has a currently active movie + */ + bool hasActiveMovie() const; + + /** + * Stops any movie currently playing for the object + */ + void stopMovie(); + + /** + * Get the current movie frame + */ + int getMovieFrame() const; + + /** + * Returns the object's frame number + */ + int getFrameNumber() const { return _frameNumber; } + + /** + * Loads a frame + */ + void loadFrame(int frameNumber); + + /** + * Load the surface + */ + void loadSurface(); + + /** + * Marks the area occupied by the object as dirty, requiring re-rendering + */ + void makeDirty(); + + /** + * Marks the area in the passed rect as dirty, and requiring re-rendering + */ + void makeDirty(const Rect &r); + + /** + * Sets whether the object is visible + */ + void setVisible(bool val); + + /** + * Return the player's passenger class + */ + int getPassengerClass() const; + + /** + * Return the player's previous passenger class + */ + int getPriorClass() const; + + /** + * Returns true if there's an attached surface which has a frame + * ready for display + */ + bool surfaceHasFrame() const; + + /** + * Finds an item in various system areas + */ + Found find(const CString &name, CGameObject **item, int findAreas); + + /** + * Returns a hidden object + */ + CGameObject *getHiddenObject(const CString &name) const; + + /** + * Sets up credits text + */ + void createCredits(); + + /** + * Support function for drag moving + */ + void dragMove(const Point &pt); + + /** + * Returns true if an item being dragged is a game object + */ + bool isObjectDragging() const; + + bool compareRoomFlags(int mode, uint flags1, uint flags2); + + /*--- CGameManager Methods ---*/ + + /** + * Return the current room + */ + CRoomItem *getRoom() const; + + /** + * Return the current node + */ + CNodeItem *getNode() const; + + /** + * Return the current room + */ + CViewItem *getView() const; + + /** + * Get the current room name + */ + CString getRoomName() const; + + /** + * Get the current node and room in the form "room.node" + */ + CString getRoomNodeName() const; + + /** + * Return the full Id of the current view in a + * room.node.view tuplet form + */ + CString getFullViewName(); + + /*--- CPetControl Methods ---*/ + + /** + * Returns the PET control + */ + CPetControl *getPetControl() const; + + /** + * Moves a specified item to the carry parcel + */ + void petAddToCarryParcel(CGameObject *obj); + + /** + * Add the item to the inventory + */ + void petAddToInventory(); + + CTreeItem *petContainerRemove(CGameObject *obj); + + bool petCheckNode(const CString &name); + + /** + * Dismiss a bot + */ + bool petDismissBot(const CString &name); + + /** + * Is Doorbot or Bellbot present in the current view + */ + bool petDoorOrBellbotPresent() const; + + /** + * Display a message in the PET + */ + void petDisplayMessage(int unused, const CString &msg); + + /** + * Display a message in the PET + */ + void petDisplayMessage(const CString &msg); + + /** + * Gets the entry number used when last arriving at the well + */ + int petGetRoomsWellEntry() const; + + /** + * Hide the PET + */ + void petHide(); + + /** + * Hides the text cursor in the current section, if applicable + */ + void petHideCursor(); + + /** + * Highlights a glyph in the currently active PET section + */ + void petHighlightGlyph(int id); + + /** + * Called when the status of an item in the inventory has changed + */ + void petInvChange(); + + /** + * Moves the item from it's original position to be under the hidden room + */ + void petMoveToHiddenRoom(); + + /** + * Gives the player a new assigned room in the specified passenger class + */ + void petReassignRoom(int passClassNum); + + /** + * Sets a new area in the PET + */ + void petSetArea(PetArea newArea) const; + + /** + * Set the remote target in the PET to this object + */ + void petSetRemoteTarget(); + + /** + * Sets the entry number for arriving at the well + */ + void petSetRoomsWellEntry(int entryNum); + + void petSetRooms1D4(int v); + + + /** + * Show the PET + */ + void petShow(); + + /** + * Shows the text cursor in the current section, if applicable + */ + void petShowCursor(); + + /** + * Summon a bot + */ + void petOnSummonBot(const CString &name, int val); + + /*--- CStarControl Methods ---*/ + + /** + * Returns the star control + */ + CStarControl *getStarControl() const; + + void starFn1(int v); + void starFn2(); + + /*--- CTrueTalkManager Methods ---*/ + + /** + * Stop a conversation with the NPC + */ + void endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view = nullptr); + + /** + * Start a conversation with the NPC + */ + void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr); + + /** + * Start a conversation with the NPC + */ + void startTalking(const CString &name, uint id, CViewItem *view = nullptr); + + /** + * Sets a dial region for a given NPC + */ + void talkSetDialRegion(const CString &name, int dialNum, int regionNum); + + /** + * Gets a dial region for a given NPC + */ + int talkGetDialRegion(const CString &name, int dialNum); + + /*--- CVideoSurface Methods ---*/ + + /** + * Signal a movie event for the given frame + */ + void movieEvent(int frameNumber); + + /** + * Signal a movie event at the end of all currently + * playing ranges + */ + void movieEvent(); + + /*--- CGameState Methods ---*/ + + void setState1C(bool flag); + void stateInc14(); + int stateGet14() const; + void stateSet24(); + int stateGet24() const; + void stateInc38(); + int stateGet38() const; + + /** + * Gets the game state node changed counter + */ + uint getNodeChangedCtr() const; + + /** + * Gets the game state node enter ticks + */ + uint getNodeEnterTicks() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GAME_OBJECT_H */ diff --git a/engines/titanic/core/game_object_desc_item.cpp b/engines/titanic/core/game_object_desc_item.cpp new file mode 100644 index 0000000000..409334c9d7 --- /dev/null +++ b/engines/titanic/core/game_object_desc_item.cpp @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/game_object_desc_item.h" + +namespace Titanic { + +CGameObjectDescItem::CGameObjectDescItem(): CTreeItem() { +} + +void CGameObjectDescItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + _clipList.save(file, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + _list1.save(file, indent); + _list2.save(file, indent); + + CTreeItem::save(file, indent); +} + +void CGameObjectDescItem::load(SimpleFile *file) { + int val = file->readNumber(); + + if (val != 1) { + if (val) + _clipList.load(file); + + _string1 = file->readString(); + _string2 = file->readString(); + _list1.load(file); + _list1.load(file); + } + + CTreeItem::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/game_object_desc_item.h b/engines/titanic/core/game_object_desc_item.h new file mode 100644 index 0000000000..7bfecaf5a2 --- /dev/null +++ b/engines/titanic/core/game_object_desc_item.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GAME_OBJECT_DESK_ITEM_H +#define TITANIC_GAME_OBJECT_DESK_ITEM_H + +#include "titanic/support/movie_clip.h" +#include "titanic/core/tree_item.h" +#include "titanic/core/list.h" + +namespace Titanic { + +class CGameObjectDescItem : public CTreeItem { +protected: + CString _string1; + CString _string2; + List<ListItem> _list1; + List<ListItem> _list2; + CMovieClipList _clipList; +public: + CLASSDEF; + CGameObjectDescItem(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GAME_OBJECT_DESK_ITEM_H */ diff --git a/engines/titanic/core/link_item.cpp b/engines/titanic/core/link_item.cpp new file mode 100644 index 0000000000..f77d081c61 --- /dev/null +++ b/engines/titanic/core/link_item.cpp @@ -0,0 +1,176 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/link_item.h" +#include "titanic/core/node_item.h" +#include "titanic/core/project_item.h" +#include "titanic/core/view_item.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CLinkItem, CNamedItem); + +CLinkItem::CLinkItem() : CNamedItem() { + _roomNumber = -1; + _nodeNumber = -1; + _viewNumber = -1; + _linkMode = 0; + _cursorId = CURSOR_ARROW; + _name = "Link"; +} + +CString CLinkItem::formName() { + CViewItem *view = findView(); + CNodeItem *node = view->findNode(); + CRoomItem *room = node->findRoom(); + + CViewItem *destView = getDestView(); + CNodeItem *destNode = destView->findNode(); + CRoomItem *destRoom = destNode->findRoom(); + + switch (_linkMode) { + case 1: + return CString::format("_PANL,%d,%s,%s", node->_nodeNumber, + view->getName().c_str(), destView->getName().c_str()); + + case 2: + return CString::format("_PANR,%d,%s,%s", node->_nodeNumber, + view->getName().c_str(), destView->getName().c_str()); + + case 3: + return CString::format("_TRACK,%d,%s,%d,%s", + node->_nodeNumber, view->getName().c_str(), + destNode->_nodeNumber, destView->getName().c_str()); + + case 4: + return CString::format("_EXIT,%d,%d,%s,%d,%d,%s", + room->_roomNumber, node->_nodeNumber, view->getName().c_str(), + destRoom->_roomNumber, destNode->_nodeNumber, destView->getName().c_str()); + + default: + return getName().c_str(); + } +} + +void CLinkItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(2, indent); + file->writeQuotedLine("L", indent); + file->writeNumberLine(_cursorId, indent + 1); + file->writeNumberLine(_linkMode, indent + 1); + file->writeNumberLine(_roomNumber, indent + 1); + file->writeNumberLine(_nodeNumber, indent + 1); + file->writeNumberLine(_viewNumber, indent + 1); + + file->writeQuotedLine("Hotspot", indent + 1); + file->writeNumberLine(_bounds.left, indent + 2); + file->writeNumberLine(_bounds.top, indent + 2); + file->writeNumberLine(_bounds.right, indent + 2); + file->writeNumberLine(_bounds.bottom, indent + 2); + + CNamedItem::save(file, indent); +} + +void CLinkItem::load(SimpleFile *file) { + int val = file->readNumber(); + file->readBuffer(); + + switch (val) { + case 2: + _cursorId = (CursorId)file->readNumber(); + // Deliberate fall-through + + case 1: + _linkMode = file->readNumber(); + // Deliberate fall-through + + case 0: + _roomNumber = file->readNumber(); + _nodeNumber = file->readNumber(); + _viewNumber = file->readNumber(); + + file->readBuffer(); + _bounds.left = file->readNumber(); + _bounds.top = file->readNumber(); + _bounds.right = file->readNumber(); + _bounds.bottom = file->readNumber(); + break; + + default: + break; + } + + CNamedItem::load(file); + + if (val < 2) { + switch (_linkMode) { + case 2: + _cursorId = CURSOR_MOVE_LEFT; + break; + case 3: + _cursorId = CURSOR_MOVE_RIGHT; + break; + case 5: + _cursorId = CURSOR_MOVE_FORWARD; + break; + default: + _cursorId = CURSOR_MOVE_FORWARD2; + break; + } + } +} + +bool CLinkItem::connectsTo(CViewItem *destView) const { + CNodeItem *destNode = destView->findNode(); + CRoomItem *destRoom = destNode->findRoom(); + + return _viewNumber == destView->_viewNumber && + _nodeNumber == destNode->_nodeNumber && + _roomNumber == destRoom->_roomNumber; +} + +void CLinkItem::setDestination(int roomNumber, int nodeNumber, + int viewNumber, int linkMode) { + _roomNumber = roomNumber; + _nodeNumber = nodeNumber; + _viewNumber = viewNumber; + _linkMode = linkMode; + + _name = formName(); +} + +CViewItem *CLinkItem::getDestView() const { + return getRoot()->findView(_roomNumber, _nodeNumber, _viewNumber); +} + +CNodeItem *CLinkItem::getDestNode() const { + return getDestView()->findNode(); +} + +CRoomItem *CLinkItem::getDestRoom() const { + return getDestNode()->findRoom(); +} + +CMovieClip *CLinkItem::getClip() const { + return findRoom()->findClip(getName()); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/link_item.h b/engines/titanic/core/link_item.h new file mode 100644 index 0000000000..dd93e2a0bf --- /dev/null +++ b/engines/titanic/core/link_item.h @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LINK_ITEM_H +#define TITANIC_LINK_ITEM_H + +#include "titanic/support/mouse_cursor.h" +#include "titanic/core/named_item.h" +#include "titanic/support/movie_clip.h" + +namespace Titanic { + +class CViewItem; +class CNodeItem; +class CRoomItem; + +class CLinkItem : public CNamedItem { + DECLARE_MESSAGE_MAP; +private: + /** + * Returns a new name for the link item, based on the + * current values for it's destination + */ + CString formName(); +protected: + int _roomNumber; + int _nodeNumber; + int _viewNumber; + int _linkMode; +public: + Rect _bounds; + CursorId _cursorId; +public: + CLASSDEF; + CLinkItem(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Returns true if the given item connects to another specified view + */ + virtual bool connectsTo(CViewItem *destView) const; + + /** + * Set the destination for the link item + */ + virtual void setDestination(int roomNumber, int nodeNumber, + int viewNumber, int linkMode); + + /** + * Get the destination view for the link item + */ + virtual CViewItem *getDestView() const; + + /** + * Get the destination node for the link item + */ + virtual CNodeItem *getDestNode() const; + + /** + * Get the destination view for the link item + */ + virtual CRoomItem *getDestRoom() const; + + /** + * Get the movie clip, if any, that's used when the link is used + */ + CMovieClip *getClip() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LINK_ITEM_H */ diff --git a/engines/titanic/core/list.cpp b/engines/titanic/core/list.cpp new file mode 100644 index 0000000000..8e90e9ff40 --- /dev/null +++ b/engines/titanic/core/list.cpp @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/list.h" + +namespace Titanic { + +void ListItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); +} + +void ListItem::load(SimpleFile *file) { + file->readNumber(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/list.h b/engines/titanic/core/list.h new file mode 100644 index 0000000000..91a74adbdc --- /dev/null +++ b/engines/titanic/core/list.h @@ -0,0 +1,164 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LIST_H +#define TITANIC_LIST_H + +#include "common/scummsys.h" +#include "common/list.h" +#include "titanic/support/simple_file.h" +#include "titanic/core/saveable_object.h" + +namespace Titanic { + +/** + * Base list item class + */ +class ListItem: public CSaveableObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +/** + * List item macro for managed pointers an item + */ +#define PTR_LIST_ITEM(T) class T##ListItem : public ListItem { \ + public: T *_item; \ + T##ListItem() : _item(nullptr) {} \ + T##ListItem(T *item) : _item(item) {} \ + virtual ~T##ListItem() { delete _item; } \ + } + +template<typename T> +class PtrListItem : public ListItem { +public: + T *_item; +public: + PtrListItem() : _item(nullptr) {} + PtrListItem(T *item) : _item(item) {} + virtual ~PtrListItem() { delete _item; } +}; + +template<typename T> +class List : public CSaveableObject, public Common::List<T *> { +public: + virtual ~List() { destroyContents(); } + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + + // Write out number of items + file->writeQuotedLine("L", indent); + file->writeNumberLine(Common::List<T *>::size(), indent); + + // Iterate through writing entries + typename Common::List<T *>::iterator i; + for (i = Common::List<T *>::begin(); i != Common::List<T *>::end(); ++i) { + ListItem *item = *i; + item->saveHeader(file, indent); + item->save(file, indent + 1); + item->saveFooter(file, indent); + } + + } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file) { + file->readNumber(); + file->readBuffer(); + + Common::List<T *>::clear(); + uint count = file->readNumber(); + + for (uint idx = 0; idx < count; ++idx) { + // Validate the class start header + if (!file->IsClassStart()) + error("Unexpected class end"); + + // Get item's class name and use it to instantiate an item + CString className = file->readString(); + T *newItem = dynamic_cast<T *>(CSaveableObject::createInstance(className)); + if (!newItem) + error("Could not create instance of %s", className.c_str()); + + // Load the item's data and add it to the list + newItem->load(file); + Common::List<T *>::push_back(newItem); + + // Validate the class end footer + if (file->IsClassStart()) + error("Unexpected class start"); + } + } + + /** + * Clear the list and destroy any items in it + */ + void destroyContents() { + typename Common::List<T *>::iterator i; + for (i = Common::List<T *>::begin(); + i != Common::List<T *>::end(); ++i) { + CSaveableObject *obj = *i; + delete obj; + } + + Common::List<T *>::clear(); + } + + /** + * Add a new item to the list of the type the list contains + */ + T *add() { + T *item = new T(); + Common::List<T *>::push_back(item); + return item; + } + + bool contains(const T *item) const { + for (typename Common::List<T *>::const_iterator i = Common::List<T *>::begin(); + i != Common::List<T *>::end(); ++i) { + if (*i == item) + return true; + } + + return false; + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIST_H */ diff --git a/engines/titanic/core/mail_man.cpp b/engines/titanic/core/mail_man.cpp new file mode 100644 index 0000000000..afe13bebad --- /dev/null +++ b/engines/titanic/core/mail_man.cpp @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/mail_man.h" + +namespace Titanic { + +void CMailMan::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CMailMan::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +CGameObject *CMailMan::getFirstObject() const { + return static_cast<CGameObject *>(getFirstChild()); +} + +CGameObject *CMailMan::getNextObject(CGameObject *prior) const { + if (!prior || prior->getParent() != this) + return nullptr; + + return static_cast<CGameObject *>(prior->getNextSibling()); +} + +void CMailMan::addMail(CGameObject *obj, int id) { + obj->detach(); + obj->addUnder(this); + setMailId(obj, id); +} + +void CMailMan::setMailId(CGameObject *obj, int id) { + obj->_id = id; + obj->_roomFlags = 0; + obj->_isMail = true; +} + +CGameObject *CMailMan::findMail(int id) const { + for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) { + if (obj->_isMail && obj->_id == id) + return obj; + } + + return nullptr; +} + +void CMailMan::removeMail(int id, int roomFlags) { + for (CGameObject *obj = getFirstObject(); obj; obj = getNextObject(obj)) { + if (obj->_isMail && obj->_id == id) { + obj->_isMail = false; + obj->_roomFlags = roomFlags; + break; + } + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/mail_man.h b/engines/titanic/core/mail_man.h new file mode 100644 index 0000000000..4c63cdfa13 --- /dev/null +++ b/engines/titanic/core/mail_man.h @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAIL_MAN_H +#define TITANIC_MAIL_MAN_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CMailMan : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CMailMan() : CGameObject(), _value(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Get the first game object stored in the PET + */ + CGameObject *getFirstObject() const; + + /** + * Get the next game object stored in the PET following + * the passed game object + */ + CGameObject *getNextObject(CGameObject *prior) const; + + /** + * Add an object to the mail list + */ + void addMail(CGameObject *obj, int id); + + /** + * Sets the mail identifier for an object + */ + static void setMailId(CGameObject *obj, int id); + + /** + * Scan the mail list for a specified item + */ + CGameObject *findMail(int id) const; + + /** + * Remove a mail item + */ + void removeMail(int id, int v); + + void resetValue() { _value = 0; } +}; + + +} // End of namespace Titanic + +#endif /* TITANIC_MAIL_MAN_H */ diff --git a/engines/titanic/core/message_target.cpp b/engines/titanic/core/message_target.cpp new file mode 100644 index 0000000000..4815d03973 --- /dev/null +++ b/engines/titanic/core/message_target.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/message_target.h" + +namespace Titanic { + +const MSGMAP *CMessageTarget::getMessageMap() const { + return getThisMessageMap(); +} + +const MSGMAP *CMessageTarget::getThisMessageMap() { + static const MSGMAP_ENTRY _messageEntries[] = { + { (PMSG)nullptr, nullptr } + }; + + static const MSGMAP messageMap = { nullptr, &_messageEntries[0] }; + return &messageMap; +} + +void CMessageTarget::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + CSaveableObject::save(file, indent); +} + +void CMessageTarget::load(SimpleFile *file) { + file->readNumber(); + CSaveableObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/message_target.h b/engines/titanic/core/message_target.h new file mode 100644 index 0000000000..a382b6392d --- /dev/null +++ b/engines/titanic/core/message_target.h @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MESSAGE_TARGET_H +#define TITANIC_MESSAGE_TARGET_H + +#include "titanic/core/saveable_object.h" + +namespace Titanic { + +class CMessageTarget; +class CMessage; + +typedef bool (CMessageTarget::*PMSG)(CMessage *msg); + +struct MSGMAP_ENTRY { + PMSG _fn; + ClassDef *_class; +}; + +struct MSGMAP { + const MSGMAP *(* pFnGetBaseMap)(); + const MSGMAP_ENTRY *lpEntries; +}; + +#define DECLARE_MESSAGE_MAP \ +protected: \ + static const MSGMAP *getThisMessageMap(); \ + virtual const MSGMAP *getMessageMap() const + +#define BEGIN_MESSAGE_MAP(theClass, baseClass) \ + const MSGMAP *theClass::getMessageMap() const \ + { return getThisMessageMap(); } \ + const MSGMAP *theClass::getThisMessageMap() \ + { \ + typedef theClass ThisClass; \ + typedef baseClass TheBaseClass; \ + typedef bool (theClass::*FNPTR)(CMessage *msg); \ + static const MSGMAP_ENTRY _messageEntries[] = { + +#define ON_MESSAGE(msgClass) \ + { static_cast<PMSG>((FNPTR)&ThisClass::msgClass), C##msgClass::_type }, + +#define END_MESSAGE_MAP() \ + { (PMSG)nullptr, nullptr } \ + }; \ + static const MSGMAP messageMap = \ + { &TheBaseClass::getThisMessageMap, &_messageEntries[0] }; \ + return &messageMap; \ + } + +#define EMPTY_MESSAGE_MAP(theClass, baseClass) \ + const MSGMAP *theClass::getMessageMap() const \ + { return getThisMessageMap(); } \ + const MSGMAP *theClass::getThisMessageMap() \ + { \ + typedef baseClass TheBaseClass; \ + static const MSGMAP_ENTRY _messageEntries[] = { \ + { (PMSG)nullptr, nullptr } \ + }; \ + static const MSGMAP messageMap = \ + { &TheBaseClass::getThisMessageMap, &_messageEntries[0] }; \ + return &messageMap; \ + } \ + enum { DUMMY } + +class CMessageTarget: public CSaveableObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MESSAGE_TARGET_H */ diff --git a/engines/titanic/core/multi_drop_target.cpp b/engines/titanic/core/multi_drop_target.cpp new file mode 100644 index 0000000000..f2998199b1 --- /dev/null +++ b/engines/titanic/core/multi_drop_target.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/multi_drop_target.h" + +namespace Titanic { + +void CMultiDropTarget::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string5, indent); + file->writeQuotedLine(_string6, indent); + + CDropTarget::save(file, indent); +} + +void CMultiDropTarget::load(SimpleFile *file) { + file->readNumber(); + _string5 = file->readString(); + _string6 = file->readString(); + + CDropTarget::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/multi_drop_target.h b/engines/titanic/core/multi_drop_target.h new file mode 100644 index 0000000000..c004b9bece --- /dev/null +++ b/engines/titanic/core/multi_drop_target.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MULTI_DROP_TARGET_H +#define TITANIC_MULTI_DROP_TARGET_H + +#include "titanic/core/drop_target.h" + +namespace Titanic { + +class CMultiDropTarget : public CDropTarget { +public: + CString _string5; + CString _string6; +public: + CLASSDEF; + CMultiDropTarget() : CDropTarget(), _string5("1,2") {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CLICK_RESPONDER_H */ diff --git a/engines/titanic/core/named_item.cpp b/engines/titanic/core/named_item.cpp new file mode 100644 index 0000000000..6eafbf8c8b --- /dev/null +++ b/engines/titanic/core/named_item.cpp @@ -0,0 +1,92 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/named_item.h" +#include "titanic/core/node_item.h" +#include "titanic/core/room_item.h" +#include "titanic/core/view_item.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CNamedItem, CTreeItem); + +CString CNamedItem::dumpItem(int indent) const { + CString result = CTreeItem::dumpItem(indent); + result += " " + _name; + + return result; +} + +void CNamedItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + file->writeQuotedLine(_name, indent); + + CTreeItem::save(file, indent); +} + +void CNamedItem::load(SimpleFile *file) { + int val = file->readNumber(); + if (!val) + _name = file->readString(); + + CTreeItem::load(file); +} + +int CNamedItem::compareTo(const CString &name, int maxLen) const { + if (maxLen) { + return getName().left(maxLen).compareToIgnoreCase(name); + } else { + return getName().compareToIgnoreCase(name); + } +} + +CViewItem *CNamedItem::findView() const { + for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { + CViewItem *view = dynamic_cast<CViewItem *>(parent); + if (view) + return view; + } + + error("Couldn't find parent view"); +} + +CNodeItem *CNamedItem::findNode() const { + for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { + CNodeItem *node = dynamic_cast<CNodeItem *>(parent); + if (node) + return node; + } + + error("Couldn't find parent node"); +} + +CRoomItem *CNamedItem::findRoom() const { + for (CTreeItem *parent = getParent(); parent; parent = parent->getParent()) { + CRoomItem *room = dynamic_cast<CRoomItem *>(parent); + if (room) + return room; + } + + error("Couldn't find parent node"); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/named_item.h b/engines/titanic/core/named_item.h new file mode 100644 index 0000000000..809cda1156 --- /dev/null +++ b/engines/titanic/core/named_item.h @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NAMED_ITEM_H +#define TITANIC_NAMED_ITEM_H + +#include "titanic/core/tree_item.h" + +namespace Titanic { + +class CViewItem; +class CNodeItem; +class CRoomItem; + +class CNamedItem: public CTreeItem { + DECLARE_MESSAGE_MAP; +public: + CString _name; +public: + CLASSDEF; + + /** + * Dump the item + */ + virtual CString dumpItem(int indent) const; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Gets the name of the item, if any + */ + virtual const CString getName() const { return _name; } + + /** + * Compares the name of the item to a passed name + */ + virtual int compareTo(const CString &name, int maxLen) const; + + /** + * Find a parent node for the item + */ + virtual CViewItem *findView() const; + + /** + * Find a parent node for the item + */ + virtual CNodeItem *findNode() const; + + /** + * Find a parent room item for the item + */ + virtual CRoomItem *findRoom() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NAMED_ITEM_H */ diff --git a/engines/titanic/core/node_item.cpp b/engines/titanic/core/node_item.cpp new file mode 100644 index 0000000000..85d3f548c0 --- /dev/null +++ b/engines/titanic/core/node_item.cpp @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/node_item.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CNodeItem, CNamedItem); + +CNodeItem::CNodeItem() : CNamedItem(), _nodeNumber(0) { +} + +void CNodeItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + file->writeQuotedLine("N", indent); + file->writeNumberLine(_nodePos.x, indent + 1); + file->writeNumberLine(_nodePos.y, indent + 1); + + file->writeQuotedLine("N", indent); + file->writeNumberLine(_nodeNumber, indent + 1); + + CNamedItem::save(file, indent); +} + +void CNodeItem::load(SimpleFile *file) { + file->readNumber(); + file->readBuffer(); + _nodePos.x = file->readNumber(); + _nodePos.y = file->readNumber(); + + file->readBuffer(); + _nodeNumber = file->readNumber(); + + CNamedItem::load(file); +} + +void CNodeItem::getPosition(double &xp, double &yp, double &zp) { + CRoomItem *room = findRoom(); + room->calcNodePosition(_nodePos, xp, yp); + zp = 0.0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/node_item.h b/engines/titanic/core/node_item.h new file mode 100644 index 0000000000..ea403ddc3a --- /dev/null +++ b/engines/titanic/core/node_item.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NODE_ITEM_H +#define TITANIC_NODE_ITEM_H + +#include "titanic/core/named_item.h" + +namespace Titanic { + +class CNodeItem : public CNamedItem { + DECLARE_MESSAGE_MAP; +public: + int _nodeNumber; + Point _nodePos; +public: + CLASSDEF; + CNodeItem(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Gets the relative position of the node within the owning room + */ + void getPosition(double &xp, double &yp, double &zp); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FILE_ITEM_H */ diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp new file mode 100644 index 0000000000..76293233b0 --- /dev/null +++ b/engines/titanic/core/project_item.cpp @@ -0,0 +1,549 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/file.h" +#include "common/savefile.h" +#include "graphics/scaler.h" +#include "graphics/thumbnail.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" +#include "titanic/core/dont_save_file_item.h" +#include "titanic/core/node_item.h" +#include "titanic/core/project_item.h" +#include "titanic/core/view_item.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +#define CURRENT_SAVEGAME_VERSION 1 +#define MAX_SAVEGAME_SLOTS 99 +#define MINIMUM_SAVEGAME_VERSION 1 + +static const char *const SAVEGAME_STR = "TNIC"; +#define SAVEGAME_STR_SIZE 4 + +EMPTY_MESSAGE_MAP(CProjectItem, CFileItem); + +void CFileListItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + file->writeQuotedLine(_name, indent); + + ListItem::save(file, indent); +} + +void CFileListItem::load(SimpleFile *file) { + file->readNumber(); + _name = file->readString(); + + ListItem::load(file); +} + +/*------------------------------------------------------------------------*/ + +CProjectItem::CProjectItem() : _nextRoomNumber(0), _nextMessageNumber(0), + _nextObjectNumber(0), _gameManager(nullptr) { +} + +void CProjectItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(6, indent); + file->writeQuotedLine("Next Avail. Object Number", indent); + file->writeNumberLine(_nextObjectNumber, indent); + file->writeQuotedLine("Next Avail. Message Number", indent); + file->writeNumberLine(_nextMessageNumber, indent); + + file->writeQuotedLine("", indent); + _files.save(file, indent); + + file->writeQuotedLine("Next Avail. Room Number", indent); + file->writeNumberLine(_nextRoomNumber, indent); + + CTreeItem::save(file, indent); +} + +void CProjectItem::buildFilesList() { + _files.destroyContents(); + + CTreeItem *treeItem = getFirstChild(); + while (treeItem) { + if (treeItem->isFileItem()) { + CString name = static_cast<CFileItem *>(treeItem)->getFilename(); + _files.add()->_name = name; + } + + treeItem = getNextSibling(); + } +} + +void CProjectItem::load(SimpleFile *file) { + int val = file->readNumber(); + _files.destroyContents(); + int count; + + switch (val) { + case 1: + file->readBuffer(); + _nextRoomNumber = file->readNumber(); + // Deliberate fall-through + + case 0: + // Load the list of files + count = file->readNumber(); + for (int idx = 0; idx < count; ++idx) { + CString name = file->readString(); + _files.add()->_name = name; + } + break; + + case 6: + file->readBuffer(); + _nextObjectNumber = file->readNumber(); + // Deliberate fall-through + + case 5: + file->readBuffer(); + _nextMessageNumber = file->readNumber(); + // Deliberate fall-through + + case 4: + file->readBuffer(); + // Deliberate fall-through + + case 2: + case 3: + _files.load(file); + file->readBuffer(); + _nextRoomNumber = file->readNumber(); + break; + + default: + break; + } + + CTreeItem::load(file); +} + +CGameManager *CProjectItem::getGameManager() const { + return _gameManager; +} + +void CProjectItem::setGameManager(CGameManager *gameManager) { + if (!_gameManager) + _gameManager = gameManager; +} + +void CProjectItem::resetGameManager() { + _gameManager = nullptr; +} + +void CProjectItem::loadGame(int slotId) { + CompressedFile file; + + // Clear any existing project contents and call preload code + clear(); + preLoad(); + + // Open either an existing savegame slot or the new game template + if (slotId >= 0) { + Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading( + g_vm->generateSaveName(slotId)); + file.open(saveFile); + } else { + Common::File *newFile = new Common::File(); + if (!newFile->open("newgame.st")) + error("Could not open newgame.st"); + file.open(newFile); + } + + // Load the savegame header in + TitanicSavegameHeader header; + readSavegameHeader(&file, header); + delete header._thumbnail; + + // Load the contents in + CProjectItem *newProject = loadData(&file); + file.IsClassStart(); + getGameManager()->load(&file); + + file.close(); + + // Clear existing project + clear(); + + // Detach each item under the loaded project, and re-attach them + // to the existing project instance (this) + CTreeItem *item; + while ((item = newProject->getFirstChild()) != nullptr) { + item->detach(); + item->addUnder(this); + } + + // Loaded project instance is no longer needed + newProject->destroyAll(); + + // Post-load processing + postLoad(); +} + +void CProjectItem::saveGame(int slotId, const CString &desc) { + CompressedFile file; + Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving( + g_vm->generateSaveName(slotId), false); + file.open(saveFile); + + // Signal the game is being saved + preSave(); + + // Write out the savegame header + TitanicSavegameHeader header; + header._saveName = desc; + writeSavegameHeader(&file, header); + + // Save the contents out + saveData(&file, this); + + // Save the game manager data + _gameManager->save(&file); + + // Close the file and signal that the saving has finished + file.close(); + postSave(); +} + +void CProjectItem::clear() { + CTreeItem *item; + while ((item = getFirstChild()) != nullptr) + item->destroyAll(); +} + +CProjectItem *CProjectItem::loadData(SimpleFile *file) { + if (!file->IsClassStart()) + return nullptr; + + CProjectItem *root = nullptr; + CTreeItem *parent = nullptr; + CTreeItem *item = nullptr; + + do { + CString entryString = file->readString(); + + if (entryString == "ALONG") { + // Move along, nothing needed + } else if (entryString == "UP") { + // Move up + if (parent == nullptr || + (parent = parent->getParent()) == nullptr) + break; + } else if (entryString == "DOWN") { + // Move down + if (parent == nullptr) + parent = item; + else + parent = parent->getLastChild(); + } else { + // Create new class instance + item = dynamic_cast<CTreeItem *>(CSaveableObject::createInstance(entryString)); + assert(item); + + if (root) { + // Already created root project + item->addUnder(parent); + } else { + root = dynamic_cast<CProjectItem *>(item); + assert(root); + root->_filename = _filename; + } + + // Load the data for the item + item->load(file); + } + + file->IsClassStart(); + } while (file->IsClassStart()); + + return root; +} + +void CProjectItem::saveData(SimpleFile *file, CTreeItem *item) const { + while (item) { + item->saveHeader(file, 0); + item->save(file, 1); + item->saveFooter(file, 0); + + CTreeItem *child = item->getFirstChild(); + if (child) { + file->write("\n{\n", 3); + file->writeQuotedString("DOWN"); + file->write("\n}\n", 3); + saveData(file, child); + file->write("\n{\n", 3); + file->writeQuotedString("UP"); + } else { + file->write("\n{\n", 3); + file->writeQuotedString("ALONG"); + } + + file->write("\n}\n", 3); + item = item->getNextSibling(); + } +} + +void CProjectItem::preLoad() { + if (_gameManager) + _gameManager->preLoad(); +} + +void CProjectItem::postLoad() { + CGameManager *gameManager = getGameManager(); + if (gameManager) + gameManager->postLoad(this); + + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->postLoad(); +} + +void CProjectItem::preSave() { + if (_gameManager) + _gameManager->preSave(this); +} + +void CProjectItem::postSave() { + if (_gameManager) + _gameManager->postSave(); +} + +CPetControl *CProjectItem::getPetControl() const { + CDontSaveFileItem *fileItem = getDontSaveFileItem(); + CTreeItem *treeItem; + + if (!fileItem || (treeItem = fileItem->getLastChild()) == nullptr) + return nullptr; + + while (treeItem) { + CPetControl *petControl = dynamic_cast<CPetControl *>(treeItem); + if (petControl) + return petControl; + + treeItem = treeItem->getPriorSibling(); + } + + return nullptr; +} + +CRoomItem *CProjectItem::findFirstRoom() const { + return dynamic_cast<CRoomItem *>(findChildInstance(CRoomItem::_type)); +} + +CTreeItem *CProjectItem::findChildInstance(ClassDef *classDef) const { + CTreeItem *treeItem = getFirstChild(); + if (treeItem == nullptr) + return nullptr; + + do { + CTreeItem *childItem = treeItem->getFirstChild(); + if (childItem) { + do { + if (childItem->isInstanceOf(classDef)) + return childItem; + } while ((childItem = childItem->getNextSibling()) != nullptr); + } + } while ((treeItem = treeItem->getNextSibling()) != nullptr); + + return nullptr; +} + +CRoomItem *CProjectItem::findNextRoom(CRoomItem *priorRoom) const { + return dynamic_cast<CRoomItem *>(findSiblingInstanceOf(CRoomItem::_type, priorRoom)); +} + +CTreeItem *CProjectItem::findSiblingInstanceOf(ClassDef *classDef, CTreeItem *startItem) const { + CTreeItem *treeItem = startItem->getParent()->getNextSibling(); + if (treeItem == nullptr) + return nullptr; + + return findChildInstance(classDef); +} + +CDontSaveFileItem *CProjectItem::getDontSaveFileItem() const { + for (CTreeItem *treeItem = getFirstChild(); treeItem; treeItem = treeItem->getNextSibling()) { + if (treeItem->isInstanceOf(CDontSaveFileItem::_type)) + return dynamic_cast<CDontSaveFileItem *>(treeItem); + } + + return nullptr; +} + +CRoomItem *CProjectItem::findHiddenRoom() { + return dynamic_cast<CRoomItem *>(findByName("HiddenRoom")); +} + +CViewItem *CProjectItem::findView(int roomNumber, int nodeNumber, int viewNumber) { + CTreeItem *treeItem = getFirstChild(); + CRoomItem *roomItem = nullptr; + + // Scan for the specified room + if (treeItem) { + do { + CTreeItem *childItem = treeItem->getFirstChild(); + CRoomItem *rItem = dynamic_cast<CRoomItem *>(childItem); + if (rItem && rItem->_roomNumber == roomNumber) { + roomItem = rItem; + break; + } + } while ((treeItem = treeItem->getNextSibling()) != nullptr); + } + if (!roomItem) + return nullptr; + + // Scan for the specified node within the room + CNodeItem *nodeItem = nullptr; + + CNodeItem *nItem = dynamic_cast<CNodeItem *>( + roomItem->findChildInstanceOf(CNodeItem::_type)); + for (; nItem && !nodeItem; nItem = dynamic_cast<CNodeItem *>( + findNextInstanceOf(CNodeItem::_type, nItem))) { + if (nItem->_nodeNumber == nodeNumber) + nodeItem = nItem; + } + if (!nodeItem) + return nullptr; + + // Scan for the specified view within the node + CViewItem *viewItem = dynamic_cast<CViewItem *>( + nodeItem->findChildInstanceOf(CViewItem::_type)); + for (; viewItem; viewItem = dynamic_cast<CViewItem *>( + findNextInstanceOf(CViewItem::_type, viewItem))) { + if (viewItem->_viewNumber == viewNumber) + return viewItem; + } + + return nullptr; +} + +SaveStateList CProjectItem::getSavegameList(const Common::String &target) { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String saveDesc; + Common::String pattern = Common::String::format("%s.0??", target.c_str()); + TitanicSavegameHeader header; + + filenames = saveFileMan->listSavefiles(pattern); + sort(filenames.begin(), filenames.end()); // Sort to get the files in numerical order + + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + const char *ext = strrchr(file->c_str(), '.'); + int slot = ext ? atoi(ext + 1) : -1; + + if (slot >= 0 && slot < MAX_SAVEGAME_SLOTS) { + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file); + + if (in) { + SimpleFile f; + f.open(in); + if (!readSavegameHeader(&f, header)) + continue; + + saveList.push_back(SaveStateDescriptor(slot, header._saveName)); + + header._thumbnail->free(); + delete header._thumbnail; + delete in; + } + } + } + + return saveList; +} + +bool CProjectItem::readSavegameHeader(SimpleFile *file, TitanicSavegameHeader &header) { + char saveIdentBuffer[SAVEGAME_STR_SIZE + 1]; + header._thumbnail = nullptr; + + // Validate the header Id + file->unsafeRead(saveIdentBuffer, SAVEGAME_STR_SIZE + 1); + if (strncmp(saveIdentBuffer, SAVEGAME_STR, SAVEGAME_STR_SIZE)) { + file->seek(-SAVEGAME_STR_SIZE, SEEK_CUR); + header._saveName = "Unnamed"; + return true; + } + + header._version = file->readByte(); + if (header._version < MINIMUM_SAVEGAME_VERSION || header._version > CURRENT_SAVEGAME_VERSION) + return false; + + // Read in the string + header._saveName.clear(); + char ch; + while ((ch = (char)file->readByte()) != '\0') header._saveName += ch; + + // Get the thumbnail + header._thumbnail = Graphics::loadThumbnail(*file); + if (!header._thumbnail) + return false; + + // Read in save date/time + header._year = file->readUint16LE(); + header._month = file->readUint16LE(); + header._day = file->readUint16LE(); + header._hour = file->readUint16LE(); + header._minute = file->readUint16LE(); + header._totalFrames = file->readUint32LE(); + + return true; +} + +void CProjectItem::writeSavegameHeader(SimpleFile *file, TitanicSavegameHeader &header) { + // Write out a savegame header + file->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1); + + file->writeByte(CURRENT_SAVEGAME_VERSION); + + // Write savegame name + file->write(header._saveName.c_str(), header._saveName.size()); + file->writeByte('\0'); + + // Create a thumbnail of the screen and save it out + Graphics::Surface *thumb = createThumbnail(); + Graphics::saveThumbnail(*file, *thumb); + thumb->free(); + delete thumb; + + // Write out the save date/time + TimeDate td; + g_system->getTimeAndDate(td); + file->writeUint16LE(td.tm_year + 1900); + file->writeUint16LE(td.tm_mon + 1); + file->writeUint16LE(td.tm_mday); + file->writeUint16LE(td.tm_hour); + file->writeUint16LE(td.tm_min); + file->writeUint32LE(g_vm->_events->getFrameCounter()); +} + +Graphics::Surface *CProjectItem::createThumbnail() { + Graphics::Surface *thumb = new Graphics::Surface(); + + ::createThumbnailFromScreen(thumb); + return thumb; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h new file mode 100644 index 0000000000..473ffd9556 --- /dev/null +++ b/engines/titanic/core/project_item.h @@ -0,0 +1,234 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PROJECT_ITEM_H +#define TITANIC_PROJECT_ITEM_H + +#include "common/scummsys.h" +#include "common/str.h" +#include "engines/savestate.h" +#include "graphics/surface.h" +#include "titanic/support/simple_file.h" +#include "titanic/core/dont_save_file_item.h" +#include "titanic/core/file_item.h" +#include "titanic/core/list.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +struct TitanicSavegameHeader { + uint8 _version; + CString _saveName; + Graphics::Surface *_thumbnail; + int _year, _month, _day; + int _hour, _minute; + int _totalFrames; +}; + + +class CGameManager; +class CPetControl; +class CViewItem; + +/** + * File list item + */ +class CFileListItem : public ListItem { +public: + CString _name; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +/** + * Filename list + */ +class CFileList: public List<CFileListItem> { +}; + +class CProjectItem : public CFileItem { + DECLARE_MESSAGE_MAP; +private: + CString _filename; + CFileList _files; + int _nextRoomNumber; + int _nextMessageNumber; + int _nextObjectNumber; + CGameManager *_gameManager; + + /** + * Called during save, iterates through the children to do some stuff + */ + void buildFilesList(); + + /** + * Called at the beginning of loading a game + */ + void preLoad(); + + /** + * Does post-loading processing + */ + void postLoad(); + + /** + * Called when a game is about to be saved + */ + void preSave(); + + /** + * Called when a game has finished being saved + */ + void postSave(); + + /** + * Finds the first child instance of a given class type + */ + CTreeItem *findChildInstance(ClassDef *classDef) const; + + /** + * Finds the next sibling occurance of a given class type + */ + CTreeItem *findSiblingInstanceOf(ClassDef *classDef, CTreeItem *startItem) const; +private: + /** + * Load project data from the passed file + */ + CProjectItem *loadData(SimpleFile *file); + + /** + * Save project data to the passed file + */ + void saveData(SimpleFile *file, CTreeItem *item) const; + + /** + * Creates a thumbnail for the current on-screen contents + */ + static Graphics::Surface *createThumbnail(); +public: + /** + * Load a list of savegames + */ + static SaveStateList getSavegameList(const Common::String &target); + + /** + * Write out the header information for a savegame + */ + static void writeSavegameHeader(SimpleFile *file, TitanicSavegameHeader &header); + + /** + * Read in the header information for a savegame + */ + static bool readSavegameHeader(SimpleFile *file, TitanicSavegameHeader &header); +public: + CLASSDEF; + CProjectItem(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Get the game manager for the project + */ + virtual CGameManager *getGameManager() const; + + /** + * Sets the game manager for the project, if not already set + */ + void setGameManager(CGameManager *gameManager); + + /** + * Get a reference to the PET control + */ + CPetControl *getPetControl() const; + + /** + * Resets the game manager field + */ + void resetGameManager(); + + /** + * Load the entire project data for a given slot Id + */ + void loadGame(int slotId); + + /** + * Save the entire project data to a given savegame slot + */ + void saveGame(int slotId, const CString &desc); + + /** + * Clear any currently loaded project + */ + void clear(); + + /** + * Set the proejct's name + */ + void setFilename(const CString &name) { _filename = name; } + + /** + * Returns a reference to the first room item in the project + */ + CRoomItem *findFirstRoom() const; + + /** + * Returns a reference to the next room following the specified room + */ + CRoomItem *findNextRoom(CRoomItem *priorRoom) const; + + /** + * Returns the don't save file item, if it exists in the project + */ + CDontSaveFileItem *getDontSaveFileItem() const; + + /** + * Finds the hidden room node of the project + */ + CRoomItem *findHiddenRoom(); + + /** + * Finds a view + */ + CViewItem *findView(int roomNumber, int nodeNumber, int viewNumber); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PROJECT_ITEM_H */ diff --git a/engines/titanic/core/resource_key.cpp b/engines/titanic/core/resource_key.cpp new file mode 100644 index 0000000000..3b390af2d4 --- /dev/null +++ b/engines/titanic/core/resource_key.cpp @@ -0,0 +1,89 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/file.h" +#include "titanic/titanic.h" +#include "titanic/support/simple_file.h" +#include "titanic/core/resource_key.h" + +namespace Titanic { + +void CResourceKey::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine("Resource Key...", indent); + file->writeQuotedLine(_key, indent); + + CSaveableObject::save(file, indent); +} + +void CResourceKey::load(SimpleFile *file) { + int val = file->readNumber(); + + if (val == 0 || val == 1) { + file->readBuffer(); + CString str = file->readString(); + setValue(str); + } + + CSaveableObject::load(file); +} + +void CResourceKey::setValue(const CString &name) { + CString nameStr = name; + nameStr.toLowercase(); + _key = nameStr; + + _value = nameStr; + int idx = _value.lastIndexOf('\\'); + if (idx >= 0) + _value = _value.mid(idx + 1); +} + +CString CResourceKey::exists() const { + CString name = _key; + + // Check for a resource being specified within an ST container + int idx = name.indexOf('#'); + if (idx >= 0) { + name = name.left(idx); + name += ".st"; + } + + // The original did tests for the file in the different + // asset paths, which aren't needed in ScummVM + Common::File f; + return f.exists(name) ? name : CString(); +} + +bool CResourceKey::scanForFile() const { + return g_vm->_filesManager->scanForFile(_value); +} + +FileType CResourceKey::fileTypeSuffix() const { + return _value.fileTypeSuffix(); +} + +ImageType CResourceKey::imageTypeSuffix() const { + return _value.imageTypeSuffix(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/resource_key.h b/engines/titanic/core/resource_key.h new file mode 100644 index 0000000000..27b23ed1e7 --- /dev/null +++ b/engines/titanic/core/resource_key.h @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RESOURCE_KEY_H +#define TITANIC_RESOURCE_KEY_H + +#include "titanic/support/string.h" +#include "titanic/core/saveable_object.h" + +namespace Titanic { + +class CResourceKey: public CSaveableObject { +private: + CString _key; + CString _value; + + void setValue(const CString &name); +public: + CLASSDEF; + CResourceKey() {} + CResourceKey(const CString &name) { setValue(name); } + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Return the key + */ + const CString &getString() const { return _key; } + + /** + * Checks whether a file for the given key exists, + * and returns it's filename if it does + */ + CString exists() const; + + /** + * Scans for a file with a matching name + */ + bool scanForFile() const; + + /** + * Returns the type of the resource based on it's extension + */ + FileType fileTypeSuffix() const; + + /** + * Returns the type of the resource based on it's extension + */ + ImageType imageTypeSuffix() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RESOURCE_KEY_H */ diff --git a/engines/titanic/core/room_item.cpp b/engines/titanic/core/room_item.cpp new file mode 100644 index 0000000000..541a8e1a9e --- /dev/null +++ b/engines/titanic/core/room_item.cpp @@ -0,0 +1,198 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/room_item.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CRoomItem, CNamedItem); + +CRoomItem::CRoomItem() : CNamedItem(), _roomNumber(0), + _roomDimensionX(0.0), _roomDimensionY(0.0) { +} + +void CRoomItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(3, indent); + file->writeQuotedLine("Exit Movies", indent); + _exitMovieKey.save(file, indent); + + file->writeQuotedLine("Room dimensions x 1000", indent); + file->writeNumberLine(_roomDimensionX * 1000.0, indent + 1); + file->writeNumberLine(_roomDimensionY * 1000.0, indent + 1); + + file->writeQuotedLine("Transition Movie", indent); + _transitionMovieKey.save(file, indent); + + file->writeQuotedLine("Movie Clip list", indent); + _clipList.save(file, indent + 1); + + file->writeQuotedLine("Room Rect", indent); + file->writeNumberLine(_roomRect.left, indent + 1); + file->writeNumberLine(_roomRect.top, indent + 1); + file->writeNumberLine(_roomRect.right, indent + 1); + file->writeNumberLine(_roomRect.bottom, indent + 1); + + file->writeQuotedLine("Room Number", indent); + file->writeNumberLine(_roomNumber, indent); + + CNamedItem::save(file, indent); +} + +void CRoomItem::load(SimpleFile *file) { + int val = file->readNumber(); + + switch (val) { + case 3: + // Read exit movie + file->readBuffer(); + _exitMovieKey.load(file); + // Deliberate fall-through + + case 2: + // Read room dimensions + file->readBuffer(); + _roomDimensionX = (double)file->readNumber() / 1000.0; + _roomDimensionY = (double)file->readNumber() / 1000.0; + // Deliberate fall-through + + case 1: + // Read transition movie key and clip list + file->readBuffer(); + _transitionMovieKey.load(file); + + file->readBuffer(); + _clipList.load(file); + postLoad(); + // Deliberate fall-through + + case 0: + // Read room rect + file->readBuffer(); + _roomRect.left = file->readNumber(); + _roomRect.top = file->readNumber(); + _roomRect.right = file->readNumber(); + _roomRect.bottom = file->readNumber(); + file->readBuffer(); + _roomNumber = file->readNumber(); + break; + + default: + break; + } + + CNamedItem::load(file); +} + +void CRoomItem::postLoad() { + if (!_exitMovieKey.exists().empty()) + return; + + CString name = _transitionMovieKey.exists(); + if (name.right(7) == "nav.avi") { + _exitMovieKey = CResourceKey(name.left(name.size() - 7) + "exit.avi"); + } +} + +void CRoomItem::calcNodePosition(const Point &nodePos, double &xVal, double &yVal) const { + xVal = yVal = 0.0; + + if (_roomDimensionX >= 0.0 && _roomDimensionY >= 0.0) { + xVal = _roomRect.width() / _roomDimensionX; + yVal = _roomRect.height() / _roomDimensionY; + + xVal = (nodePos.x - _roomRect.left) / xVal; + yVal = (nodePos.y - _roomRect.top) / yVal; + } +} + +int CRoomItem::getScriptId() const { + CString name = getName(); + if (name == "1stClassLobby") + return 130; + else if (name == "1stClassRestaurant") + return 132; + else if (name == "1stClassState") + return 131; + else if (name == "2ndClassLobby") + return 128; + else if (name == "Bar") + return 112; + else if (name == "BottomOfWell") + return 108; + else if (name == "Bridge") + return 121; + else if (name == "Dome") + return 122; + else if (name == "Home") + return 100; + else if (name == "Lift") + return 103; + else if (name == "MusicRoom") + return 117; + else if (name == "MusicRoomLobby") + return 118; + else if (name == "ParrotLobby") + return 111; + else if (name == "Pellerator") + return 104; + else if (name == "PromenadeDeck") + return 114; + else if (name == "SculptureChamber") + return 116; + else if (name == "secClassState") + return 129; + else if (name == "ServiceElevator") + return 102; + else if (name == "SGTLeisure") + return 125; + else if (name == "SGTLittleLift") + return 105; + else if (name == "SgtLobby") + return 124; + else if (name == "SGTState") + return 126; + else if (name == "Titania") + return 123; + else if (name == "TopOfWell") + return 107; + else if (name == "EmbLobby" || name == "MoonEmbLobby") + return 110; + else if (name == "CreatorsChamber" || name == "CreatorsChamberOn") + return 113; + else if (name == "Arboretum" || name == "FrozenArboretum") + return 115; + else if (name == "BilgeRoom" || name == "BilgeRoomWith") + return 101; + + return 0; +} + +CResourceKey CRoomItem::getTransitionMovieKey() { + _transitionMovieKey.scanForFile(); + return _transitionMovieKey; +} + +CResourceKey CRoomItem::getExitMovieKey() { + return _exitMovieKey; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/room_item.h b/engines/titanic/core/room_item.h new file mode 100644 index 0000000000..cb343a15d2 --- /dev/null +++ b/engines/titanic/core/room_item.h @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ROOM_ITEM_H +#define TITANIC_ROOM_ITEM_H + +#include "titanic/support/rect.h" +#include "titanic/core/list.h" +#include "titanic/support/movie_clip.h" +#include "titanic/core/named_item.h" +#include "titanic/core/resource_key.h" + +namespace Titanic { + +class CRoomItem : public CNamedItem { + DECLARE_MESSAGE_MAP; +private: + /** + * Handles post-load processing + */ + void postLoad(); +public: + Rect _roomRect; + CMovieClipList _clipList; + int _roomNumber; + CResourceKey _transitionMovieKey; + CResourceKey _exitMovieKey; + double _roomDimensionX, _roomDimensionY; +public: + CLASSDEF; + CRoomItem(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Return a movie clip for the room by name + */ + CMovieClip *findClip(const CString &name) { return _clipList.findByName(name); } + + /** + * Calculates the positioning of a node within the overall room + */ + void calcNodePosition(const Point &nodePos, double &xVal, double &yVal) const; + + /** + * Get the TrueTalk script Id associated with the room + */ + int getScriptId() const; + + CResourceKey getTransitionMovieKey(); + + CResourceKey getExitMovieKey(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ROOM_ITEM_H */ diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp new file mode 100644 index 0000000000..62cee47045 --- /dev/null +++ b/engines/titanic/core/saveable_object.cpp @@ -0,0 +1,1642 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/carry/arm.h" +#include "titanic/carry/auditory_centre.h" +#include "titanic/carry/bowl_ear.h" +#include "titanic/carry/brain.h" +#include "titanic/carry/bridge_piece.h" +#include "titanic/carry/carry.h" +#include "titanic/carry/carry_parrot.h" +#include "titanic/carry/central_core.h" +#include "titanic/carry/chicken.h" +#include "titanic/carry/crushed_tv.h" +#include "titanic/carry/eye.h" +#include "titanic/carry/feathers.h" +#include "titanic/carry/fruit.h" +#include "titanic/carry/glass.h" +#include "titanic/carry/hammer.h" +#include "titanic/carry/head_piece.h" +#include "titanic/carry/hose.h" +#include "titanic/carry/hose_end.h" +#include "titanic/carry/key.h" +#include "titanic/carry/liftbot_head.h" +#include "titanic/carry/long_stick.h" +#include "titanic/carry/magazine.h" +#include "titanic/carry/maitred_left_arm.h" +#include "titanic/carry/maitred_right_arm.h" +#include "titanic/carry/mouth.h" +#include "titanic/carry/napkin.h" +#include "titanic/carry/nose.h" +#include "titanic/carry/note.h" +#include "titanic/carry/parcel.h" +#include "titanic/carry/perch.h" +#include "titanic/carry/phonograph_cylinder.h" +#include "titanic/carry/phonograph_ear.h" +#include "titanic/carry/photograph.h" +#include "titanic/carry/plug_in.h" +#include "titanic/carry/speech_centre.h" +#include "titanic/carry/sweets.h" +#include "titanic/carry/vision_centre.h" + +#include "titanic/core/saveable_object.h" +#include "titanic/core/background.h" +#include "titanic/core/click_responder.h" +#include "titanic/core/dont_save_file_item.h" +#include "titanic/core/drop_target.h" +#include "titanic/core/file_item.h" +#include "titanic/core/game_object.h" +#include "titanic/core/game_object_desc_item.h" +#include "titanic/core/link_item.h" +#include "titanic/core/list.h" +#include "titanic/core/mail_man.h" +#include "titanic/core/message_target.h" +#include "titanic/support/movie_clip.h" +#include "titanic/core/multi_drop_target.h" +#include "titanic/core/node_item.h" +#include "titanic/core/project_item.h" +#include "titanic/core/room_item.h" +#include "titanic/core/saveable_object.h" +#include "titanic/core/static_image.h" +#include "titanic/core/turn_on_object.h" +#include "titanic/core/turn_on_play_sound.h" +#include "titanic/core/turn_on_turn_off.h" +#include "titanic/core/tree_item.h" +#include "titanic/core/view_item.h" + +#include "titanic/game/announce.h" +#include "titanic/game/annoy_barbot.h" +#include "titanic/game/arb_background.h" +#include "titanic/game/arboretum_gate.h" +#include "titanic/game/auto_animate.h" +#include "titanic/game/bar_bell.h" +#include "titanic/game/bar_menu.h" +#include "titanic/game/bar_menu_button.h" +#include "titanic/game/belbot_get_light.h" +#include "titanic/game/bilge_succubus.h" +#include "titanic/game/bomb.h" +#include "titanic/game/bottom_of_well_monitor.h" +#include "titanic/game/bowl_unlocker.h" +#include "titanic/game/brain_slot.h" +#include "titanic/game/bridge_door.h" +#include "titanic/game/bridge_view.h" +#include "titanic/game/broken_pell_base.h" +#include "titanic/game/broken_pellerator.h" +#include "titanic/game/broken_pellerator_froz.h" +#include "titanic/game/cage.h" +#include "titanic/game/call_pellerator.h" +#include "titanic/game/captains_wheel.h" +#include "titanic/game/cdrom.h" +#include "titanic/game/cdrom_computer.h" +#include "titanic/game/cdrom_tray.h" +#include "titanic/game/cell_point_button.h" +#include "titanic/game/chev_code.h" +#include "titanic/game/chev_panel.h" +#include "titanic/game/chicken_cooler.h" +#include "titanic/game/chicken_dispensor.h" +#include "titanic/game/close_broken_pel.h" +#include "titanic/game/computer.h" +#include "titanic/game/computer_screen.h" +#include "titanic/game/code_wheel.h" +#include "titanic/game/cookie.h" +#include "titanic/game/credits.h" +#include "titanic/game/credits_button.h" +#include "titanic/game/dead_area.h" +#include "titanic/game/desk_click_responder.h" +#include "titanic/game/doorbot_elevator_handler.h" +#include "titanic/game/doorbot_home_handler.h" +#include "titanic/game/ear_sweet_bowl.h" +#include "titanic/game/eject_phonograph_button.h" +#include "titanic/game/elevator_action_area.h" +#include "titanic/game/emma_control.h" +#include "titanic/game/empty_nut_bowl.h" +#include "titanic/game/end_credit_text.h" +#include "titanic/game/end_credits.h" +#include "titanic/game/end_explode_ship.h" +#include "titanic/game/end_game_credits.h" +#include "titanic/game/end_sequence_control.h" +#include "titanic/game/fan.h" +#include "titanic/game/fan_control.h" +#include "titanic/game/fan_decrease.h" +#include "titanic/game/fan_increase.h" +#include "titanic/game/fan_noises.h" +#include "titanic/game/floor_indicator.h" +#include "titanic/game/games_console.h" +#include "titanic/game/get_lift_eye2.h" +#include "titanic/game/glass_smasher.h" +#include "titanic/game/hammer_clip.h" +#include "titanic/game/hammer_dispensor.h" +#include "titanic/game/hammer_dispensor_button.h" +#include "titanic/game/head_slot.h" +#include "titanic/game/head_smash_event.h" +#include "titanic/game/head_smash_lever.h" +#include "titanic/game/head_spinner.h" +#include "titanic/game/idle_summoner.h" +#include "titanic/game/leave_sec_class_state.h" +#include "titanic/game/lemon_dispensor.h" +#include "titanic/game/light.h" +#include "titanic/game/light_switch.h" +#include "titanic/game/little_lift_button.h" +#include "titanic/game/long_stick_dispenser.h" +#include "titanic/game/missiveomat.h" +#include "titanic/game/missiveomat_button.h" +#include "titanic/game/movie_tester.h" +#include "titanic/game/musical_instrument.h" +#include "titanic/game/music_console_button.h" +#include "titanic/game/music_room_phonograph.h" +#include "titanic/game/music_room_stop_phonograph_button.h" +#include "titanic/game/music_system_lock.h" +#include "titanic/game/nav_helmet.h" +#include "titanic/game/navigation_computer.h" +#include "titanic/game/no_nut_bowl.h" +#include "titanic/game/nose_holder.h" +#include "titanic/game/null_port_hole.h" +#include "titanic/game/nut_replacer.h" +#include "titanic/game/pet_disabler.h" +#include "titanic/game/phonograph.h" +#include "titanic/game/phonograph_lid.h" +#include "titanic/game/play_music_button.h" +#include "titanic/game/play_on_act.h" +#include "titanic/game/port_hole.h" +#include "titanic/game/record_phonograph_button.h" +#include "titanic/game/replacement_ear.h" +#include "titanic/game/reserved_table.h" +#include "titanic/game/restaurant_cylinder_holder.h" +#include "titanic/game/restaurant_phonograph.h" +#include "titanic/game/sauce_dispensor.h" +#include "titanic/game/search_point.h" +#include "titanic/game/season_background.h" +#include "titanic/game/season_barrel.h" +#include "titanic/game/seasonal_adjustment.h" +#include "titanic/game/service_elevator_window.h" +#include "titanic/game/ship_setting.h" +#include "titanic/game/ship_setting_button.h" +#include "titanic/game/show_cell_points.h" +#include "titanic/game/speech_dispensor.h" +#include "titanic/game/splash_animation.h" +#include "titanic/game/starling_puret.h" +#include "titanic/game/start_action.h" +#include "titanic/game/stop_phonograph_button.h" +#include "titanic/game/sub_glass.h" +#include "titanic/game/sub_wrapper.h" +#include "titanic/game/sweet_bowl.h" +#include "titanic/game/television.h" +#include "titanic/game/third_class_canal.h" +#include "titanic/game/throw_tv_down_well.h" +#include "titanic/game/titania_still_control.h" +#include "titanic/game/tow_parrot_nav.h" +#include "titanic/game/up_lighter.h" +#include "titanic/game/useless_lever.h" +#include "titanic/game/volume_control.h" +#include "titanic/game/wheel_button.h" +#include "titanic/game/wheel_hotspot.h" +#include "titanic/game/wheel_spin.h" +#include "titanic/game/wheel_spin_horn.h" +#include "titanic/game/gondolier/gondolier_base.h" +#include "titanic/game/gondolier/gondolier_chest.h" +#include "titanic/game/gondolier/gondolier_face.h" +#include "titanic/game/gondolier/gondolier_mixer.h" +#include "titanic/game/gondolier/gondolier_slider.h" +#include "titanic/game/maitred/maitred_arm_holder.h" +#include "titanic/game/maitred/maitred_body.h" +#include "titanic/game/maitred/maitred_legs.h" +#include "titanic/game/maitred/maitred_prod_receptor.h" +#include "titanic/game/parrot/parrot_lobby_controller.h" +#include "titanic/game/parrot/parrot_lobby_link_updater.h" +#include "titanic/game/parrot/parrot_lobby_object.h" +#include "titanic/game/parrot/parrot_lobby_view_object.h" +#include "titanic/game/parrot/parrot_loser.h" +#include "titanic/game/parrot/parrot_nut_bowl_actor.h" +#include "titanic/game/parrot/parrot_nut_eater.h" +#include "titanic/game/parrot/parrot_perch_holder.h" +#include "titanic/game/parrot/parrot_succubus.h" +#include "titanic/game/parrot/parrot_trigger.h" +#include "titanic/game/parrot/player_meets_parrot.h" +#include "titanic/game/pet/pet.h" +#include "titanic/game/pet/pet_class1.h" +#include "titanic/game/pet/pet_class2.h" +#include "titanic/game/pet/pet_class3.h" +#include "titanic/game/pet/pet_lift.h" +#include "titanic/game/pet/pet_monitor.h" +#include "titanic/game/pet/pet_pellerator.h" +#include "titanic/game/pet/pet_position.h" +#include "titanic/game/pet/pet_sentinal.h" +#include "titanic/game/pet/pet_sounds.h" +#include "titanic/game/pet/pet_transition.h" +#include "titanic/game/pet/pet_transport.h" +#include "titanic/game/pickup/pick_up.h" +#include "titanic/game/pickup/pick_up_bar_glass.h" +#include "titanic/game/pickup/pick_up_hose.h" +#include "titanic/game/pickup/pick_up_lemon.h" +#include "titanic/game/pickup/pick_up_speech_centre.h" +#include "titanic/game/pickup/pick_up_vis_centre.h" +#include "titanic/game/placeholder/bar_shelf_vis_centre.h" +#include "titanic/game/placeholder/lemon_on_bar.h" +#include "titanic/game/placeholder/place_holder_item.h" +#include "titanic/game/placeholder/tv_on_bar.h" +#include "titanic/game/sgt/armchair.h" +#include "titanic/game/sgt/basin.h" +#include "titanic/game/sgt/bedfoot.h" +#include "titanic/game/sgt/bedhead.h" +#include "titanic/game/sgt/chest_of_drawers.h" +#include "titanic/game/sgt/desk.h" +#include "titanic/game/sgt/deskchair.h" +#include "titanic/game/sgt/drawer.h" +#include "titanic/game/sgt/sgt_doors.h" +#include "titanic/game/sgt/sgt_nav.h" +#include "titanic/game/sgt/sgt_navigation.h" +#include "titanic/game/sgt/sgt_restaurant_doors.h" +#include "titanic/game/sgt/sgt_state_control.h" +#include "titanic/game/sgt/sgt_state_room.h" +#include "titanic/game/sgt/sgt_tv.h" +#include "titanic/game/sgt/sgt_upper_doors_sound.h" +#include "titanic/game/sgt/toilet.h" +#include "titanic/game/sgt/vase.h" +#include "titanic/game/sgt/washstand.h" +#include "titanic/game/transport/gondolier.h" +#include "titanic/game/transport/lift.h" +#include "titanic/game/transport/lift_indicator.h" +#include "titanic/game/transport/pellerator.h" +#include "titanic/game/transport/service_elevator.h" +#include "titanic/game/transport/transport.h" +#include "titanic/gfx/act_button.h" +#include "titanic/gfx/changes_season_button.h" +#include "titanic/gfx/chev_left_off.h" +#include "titanic/gfx/chev_left_on.h" +#include "titanic/gfx/chev_right_off.h" +#include "titanic/gfx/chev_right_on.h" +#include "titanic/gfx/chev_send_rec_switch.h" +#include "titanic/gfx/chev_switch.h" +#include "titanic/gfx/edit_control.h" +#include "titanic/gfx/elevator_button.h" +#include "titanic/gfx/get_from_succ.h" +#include "titanic/gfx/helmet_on_off.h" +#include "titanic/gfx/home_photo.h" +#include "titanic/gfx/icon_nav_action.h" +#include "titanic/gfx/icon_nav_butt.h" +#include "titanic/gfx/icon_nav_down.h" +#include "titanic/gfx/icon_nav_image.h" +#include "titanic/gfx/icon_nav_left.h" +#include "titanic/gfx/icon_nav_receive.h" +#include "titanic/gfx/icon_nav_right.h" +#include "titanic/gfx/icon_nav_send.h" +#include "titanic/gfx/icon_nav_up.h" +#include "titanic/gfx/keybrd_butt.h" +#include "titanic/gfx/move_object_button.h" +#include "titanic/gfx/music_control.h" +#include "titanic/gfx/music_slider_pitch.h" +#include "titanic/gfx/music_slider_speed.h" +#include "titanic/gfx/music_switch.h" +#include "titanic/gfx/music_switch_inversion.h" +#include "titanic/gfx/music_switch_reverse.h" +#include "titanic/gfx/music_voice_mute.h" +#include "titanic/gfx/send_to_succ.h" +#include "titanic/gfx/sgt_selector.h" +#include "titanic/gfx/slider_button.h" +#include "titanic/gfx/small_chev_left_off.h" +#include "titanic/gfx/small_chev_left_on.h" +#include "titanic/gfx/small_chev_right_off.h" +#include "titanic/gfx/small_chev_right_on.h" +#include "titanic/gfx/status_change_button.h" +#include "titanic/gfx/st_button.h" +#include "titanic/gfx/toggle_button.h" +#include "titanic/gfx/text_down.h" +#include "titanic/gfx/text_skrew.h" +#include "titanic/gfx/text_up.h" +#include "titanic/gfx/toggle_switch.h" + +#include "titanic/messages/messages.h" +#include "titanic/messages/auto_sound_event.h" +#include "titanic/messages/bilge_auto_sound_event.h" +#include "titanic/messages/bilge_dispensor_event.h" +#include "titanic/messages/door_auto_sound_event.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/messages/pet_messages.h" +#include "titanic/messages/service_elevator_door.h" + +#include "titanic/moves/enter_bomb_room.h" +#include "titanic/moves/enter_bridge.h" +#include "titanic/moves/enter_exit_first_class_state.h" +#include "titanic/moves/enter_exit_mini_lift.h" +#include "titanic/moves/enter_exit_sec_class_mini_lift.h" +#include "titanic/moves/enter_exit_view.h" +#include "titanic/moves/enter_sec_class_state.h" +#include "titanic/moves/exit_arboretum.h" +#include "titanic/moves/exit_bridge.h" +#include "titanic/moves/exit_lift.h" +#include "titanic/moves/exit_pellerator.h" +#include "titanic/moves/exit_state_room.h" +#include "titanic/moves/exit_tiania.h" +#include "titanic/moves/move_player_in_parrot_room.h" +#include "titanic/moves/move_player_to.h" +#include "titanic/moves/move_player_to_from.h" +#include "titanic/moves/multi_move.h" +#include "titanic/moves/pan_from_pel.h" +#include "titanic/moves/restaurant_pan_handler.h" +#include "titanic/moves/restricted_move.h" +#include "titanic/moves/scraliontis_table.h" +#include "titanic/moves/trip_down_canal.h" + +#include "titanic/npcs/barbot.h" +#include "titanic/npcs/bellbot.h" +#include "titanic/npcs/callbot.h" +#include "titanic/npcs/deskbot.h" +#include "titanic/npcs/doorbot.h" +#include "titanic/npcs/liftbot.h" +#include "titanic/npcs/maitre_d.h" +#include "titanic/npcs/mobile.h" +#include "titanic/npcs/parrot.h" +#include "titanic/npcs/starlings.h" +#include "titanic/npcs/succubus.h" +#include "titanic/npcs/summon_bots.h" +#include "titanic/npcs/titania.h" +#include "titanic/npcs/true_talk_npc.h" + +#include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_drag_chev.h" +#include "titanic/pet_control/pet_graphic.h" +#include "titanic/pet_control/pet_graphic2.h" +#include "titanic/pet_control/pet_leaf.h" +#include "titanic/pet_control/pet_mode_off.h" +#include "titanic/pet_control/pet_mode_on.h" +#include "titanic/pet_control/pet_mode_panel.h" +#include "titanic/pet_control/pet_pannel1.h" +#include "titanic/pet_control/pet_pannel2.h" +#include "titanic/pet_control/pet_pannel3.h" + +#include "titanic/sound/auto_music_player.h" +#include "titanic/sound/auto_music_player_base.h" +#include "titanic/sound/auto_sound_player.h" +#include "titanic/sound/auto_sound_player_adsr.h" +#include "titanic/sound/background_sound_maker.h" +#include "titanic/sound/bird_song.h" +#include "titanic/sound/dome_from_top_of_well.h" +#include "titanic/sound/gondolier_song.h" +#include "titanic/sound/enter_view_toggles_other_music.h" +#include "titanic/sound/music_player.h" +#include "titanic/sound/node_auto_sound_player.h" +#include "titanic/sound/restricted_auto_music_player.h" +#include "titanic/sound/room_auto_sound_player.h" +#include "titanic/sound/room_trigger_auto_music_player.h" +#include "titanic/sound/season_noises.h" +#include "titanic/sound/seasonal_music_player.h" +#include "titanic/sound/titania_speech.h" +#include "titanic/sound/trigger_auto_music_player.h" +#include "titanic/sound/view_auto_sound_player.h" +#include "titanic/sound/view_toggles_other_music.h" +#include "titanic/sound/water_lapping_sounds.h" + +#include "titanic/star_control/star_control.h" +#include "titanic/support/time_event_info.h" + +namespace Titanic { + +CSaveableObject *ClassDef::create() { + return new CSaveableObject(); +} + +/*------------------------------------------------------------------------*/ + +Common::HashMap<Common::String, CSaveableObject::CreateFunction> * + CSaveableObject::_classList = nullptr; +Common::List<ClassDef *> *CSaveableObject::_classDefs; + +#define DEFFN(T) CSaveableObject *Function##T() { return new T(); } \ + ClassDef *T::_type +#define ADDFN(CHILD, PARENT) \ + CHILD::_type = new TypeTemplate<CHILD>(#CHILD, PARENT::_type); \ + (*_classList)[#CHILD] = Function##CHILD + +DEFFN(CArm); +DEFFN(CAuditoryCentre); +DEFFN(CBowlEar); +DEFFN(CBrain); +DEFFN(CBridgePiece); +DEFFN(CCarry); +DEFFN(CCarryParrot); +DEFFN(CCentralCore); +DEFFN(CChicken); +DEFFN(CCrushedTV); +DEFFN(CEar); +DEFFN(CEye); +DEFFN(CFeathers); +DEFFN(CFruit); +DEFFN(CGlass); +DEFFN(CHammer); +DEFFN(CHeadPiece); +DEFFN(CHose); +DEFFN(CHoseEnd); +DEFFN(CKey); +DEFFN(CLiftbotHead); +DEFFN(CLongStick); +DEFFN(CMagazine); +DEFFN(CMaitreDLeftArm); +DEFFN(CMaitreDRightArm); +DEFFN(CMouth); +DEFFN(CNapkin); +DEFFN(CNose); +DEFFN(CNote); +DEFFN(CParcel); +DEFFN(CPerch); +DEFFN(CPhonographCylinder); +DEFFN(CPhonographEar); +DEFFN(CPhotograph); +DEFFN(CPlugIn); +DEFFN(CSpeechCentre); +DEFFN(CSweets); +DEFFN(CVisionCentre); + +DEFFN(CBackground); +DEFFN(CClickResponder); +DEFFN(CDontSaveFileItem); +DEFFN(CDropTarget); +DEFFN(CFileItem); +DEFFN(CFileListItem); +DEFFN(CGameObject); +DEFFN(CGameObjectDescItem); +DEFFN(CLinkItem); +DEFFN(ListItem); +DEFFN(CMailMan); +DEFFN(CMessageTarget); +DEFFN(CMovieClip); +DEFFN(CMultiDropTarget); +DEFFN(CNamedItem); +DEFFN(CNodeItem); +DEFFN(CProjectItem); +DEFFN(CResourceKey); +DEFFN(CRoomItem); +DEFFN(CSaveableObject); +DEFFN(CStaticImage); +DEFFN(CTurnOnObject); +DEFFN(CTurnOnPlaySound); +DEFFN(CTurnOnTurnOff); +DEFFN(CTreeItem); +DEFFN(CViewItem); + +DEFFN(CAnnounce); +DEFFN(CAnnoyBarbot); +DEFFN(CArbBackground); +DEFFN(CArboretumGate); +DEFFN(CAutoAnimate); +DEFFN(CBarBell); +DEFFN(CBarMenu); +DEFFN(CBarMenuButton); +DEFFN(CBelbotGetLight); +DEFFN(CBilgeSuccUBus); +DEFFN(CBomb); +DEFFN(CBottomOfWellMonitor); +DEFFN(CBowlUnlocker); +DEFFN(CBrainSlot); +DEFFN(CBridgeDoor); +DEFFN(CBridgeView); +DEFFN(CBrokenPellBase); +DEFFN(CBrokenPellerator); +DEFFN(CBrokenPelleratorFroz); +DEFFN(CCage); +DEFFN(CCallPellerator); +DEFFN(CCaptainsWheel); +DEFFN(CCDROM); +DEFFN(CCDROMComputer); +DEFFN(CCDROMTray); +DEFFN(CCellPointButton); +DEFFN(CChevCode); +DEFFN(CChevPanel); +DEFFN(CChickenCooler); +DEFFN(CChickenDispensor); +DEFFN(CCloseBrokenPel); +DEFFN(CodeWheel); +DEFFN(CComputer); +DEFFN(CComputerScreen); +DEFFN(CCookie); +DEFFN(CCredits); +DEFFN(CCreditsButton); +DEFFN(CDeadArea); +DEFFN(CDeskClickResponder); +DEFFN(CDoorbotElevatorHandler); +DEFFN(CDoorbotHomeHandler); +DEFFN(CEarSweetBowl); +DEFFN(CEjectPhonographButton); +DEFFN(CElevatorActionArea); +DEFFN(CEmmaControl); +DEFFN(CEmptyNutBowl); +DEFFN(CEndCreditText); +DEFFN(CEndCredits); +DEFFN(CEndExplodeShip); +DEFFN(CEndGameCredits); +DEFFN(CEndSequenceControl); +DEFFN(CFan); +DEFFN(CFanControl); +DEFFN(CFanDecrease); +DEFFN(CFanIncrease); +DEFFN(CFanNoises); +DEFFN(CFloorIndicator); +DEFFN(CGamesConsole); +DEFFN(CGetLiftEye2); +DEFFN(CGlassSmasher); +DEFFN(CHammerClip); +DEFFN(CHammerDispensor); +DEFFN(CHammerDispensorButton); +DEFFN(CHeadSlot); +DEFFN(CHeadSmashEvent); +DEFFN(CHeadSmashLever); +DEFFN(CHeadSpinner); +DEFFN(CIdleSummoner); +DEFFN(CLeaveSecClassState); +DEFFN(CLemonDispensor); +DEFFN(CLight); +DEFFN(CLightSwitch); +DEFFN(CLittleLiftButton); +DEFFN(CLongStickDispenser); +DEFFN(CMissiveOMat); +DEFFN(CMissiveOMatButton); +DEFFN(CMovieTester); +DEFFN(CMusicalInstrument); +DEFFN(CMusicConsoleButton); +DEFFN(CMusicRoomPhonograph); +DEFFN(CMusicRoomStopPhonographButton); +DEFFN(CMusicSystemLock); +DEFFN(CNavHelmet); +DEFFN(CNavigationComputer); +DEFFN(CNoNutBowl); +DEFFN(CNoseHolder); +DEFFN(CNullPortHole); +DEFFN(CNutReplacer); +DEFFN(CPetDisabler); +DEFFN(CPhonograph); +DEFFN(CPhonographLid); +DEFFN(CPlayMusicButton); +DEFFN(CPlayOnAct); +DEFFN(CPortHole); +DEFFN(CRecordPhonographButton); +DEFFN(CReplacementEar); +DEFFN(CReservedTable); +DEFFN(CRestaurantCylinderHolder); +DEFFN(CRestaurantPhonograph); +DEFFN(CSauceDispensor); +DEFFN(CSearchPoint); +DEFFN(CSeasonBackground); +DEFFN(CSeasonBarrel); +DEFFN(CSeasonalAdjustment); +DEFFN(CServiceElevatorWindow); +DEFFN(CShipSetting); +DEFFN(CShipSettingButton); +DEFFN(CShowCellpoints); +DEFFN(CSpeechDispensor); +DEFFN(CSplashAnimation); +DEFFN(CStarlingPuret); +DEFFN(CStartAction); +DEFFN(CStopPhonographButton); +DEFFN(CSUBGlass); +DEFFN(CSUBWrapper); +DEFFN(CSweetBowl); +DEFFN(CTelevision); +DEFFN(CThirdClassCanal); +DEFFN(CThrowTVDownWell); +DEFFN(CTitaniaStillControl); +DEFFN(CTOWParrotNav); +DEFFN(CUpLighter); +DEFFN(CUselessLever); +DEFFN(CVolumeControl); +DEFFN(CWheelButton); +DEFFN(CWheelHotSpot); +DEFFN(CWheelSpin); +DEFFN(CWheelSpinHorn); +DEFFN(CGondolierBase); +DEFFN(CGondolierChest); +DEFFN(CGondolierFace); +DEFFN(CGondolierMixer); +DEFFN(CGondolierSlider); +DEFFN(CMaitreDArmHolder); +DEFFN(CMaitreDBody); +DEFFN(CMaitreDLegs); +DEFFN(CMaitreDProdReceptor); +DEFFN(CParrotLobbyController); +DEFFN(CParrotLobbyLinkUpdater); +DEFFN(CParrotLobbyObject); +DEFFN(CParrotLobbyViewObject); +DEFFN(CParrotLoser); +DEFFN(CParrotNutBowlActor); +DEFFN(CParrotNutEater); +DEFFN(CParrotPerchHolder); +DEFFN(CParrotSuccUBus); +DEFFN(CParrotTrigger); +DEFFN(CPlayerMeetsParrot); +DEFFN(CPET); +DEFFN(CPETClass1); +DEFFN(CPETClass2); +DEFFN(CPETClass3); +DEFFN(CPetControl); +DEFFN(CPetDragChev); +DEFFN(CPetGraphic); +DEFFN(CPetGraphic2); +DEFFN(PETLeaf); +DEFFN(CPETLift); +DEFFN(CPETMonitor); +DEFFN(CPETPellerator); +DEFFN(CPETPosition); +DEFFN(CPETSentinal); +DEFFN(CPETSounds); +DEFFN(CPETTransition); +DEFFN(CPETTransport); +DEFFN(CPickUp); +DEFFN(CPickUpBarGlass); +DEFFN(CPickUpHose); +DEFFN(CPickUpLemon); +DEFFN(CPickUpSpeechCentre); +DEFFN(CPickUpVisCentre); +DEFFN(CBarShelfVisCentre); +DEFFN(CLemonOnBar); +DEFFN(CPlaceHolderItem); +DEFFN(CTVOnBar); +DEFFN(CArmchair); +DEFFN(CBasin); +DEFFN(CBedfoot); +DEFFN(CBedhead); +DEFFN(CChestOfDrawers); +DEFFN(CDesk); +DEFFN(CDeskchair); +DEFFN(CDrawer); +DEFFN(CSGTDoors); +DEFFN(SGTNav); +DEFFN(CSGTNavigation); +DEFFN(CSGTRestaurantDoors); +DEFFN(CSGTStateControl); +DEFFN(CSGTStateRoom); +DEFFN(CSGTTV); +DEFFN(CSGTUpperDoorsSound); +DEFFN(CToilet); +DEFFN(CVase); +DEFFN(CWashstand); + +DEFFN(CGondolier); +DEFFN(CLift); +DEFFN(CLiftindicator); +DEFFN(CPellerator); +DEFFN(CServiceElevator); +DEFFN(CTransport); + +DEFFN(CActButton); +DEFFN(CChangesSeasonButton); +DEFFN(CChevLeftOff); +DEFFN(CChevLeftOn); +DEFFN(CChevRightOff); +DEFFN(CChevRightOn); +DEFFN(CChevSendRecSwitch); +DEFFN(CChevSwitch); +DEFFN(CEditControl); +DEFFN(CElevatorButton); +DEFFN(CGetFromSucc); +DEFFN(CHelmetOnOff); +DEFFN(CHomePhoto); +DEFFN(CIconNavAction); +DEFFN(CIconNavButt); +DEFFN(CIconNavDown); +DEFFN(CIconNavImage); +DEFFN(CIconNavLeft); +DEFFN(CIconNavReceive); +DEFFN(CIconNavRight); +DEFFN(CIconNavSend); +DEFFN(CIconNavUp); +DEFFN(CKeybrdButt); +DEFFN(CMoveObjectButton); +DEFFN(CMusicControl); +DEFFN(CMusicSlider); +DEFFN(CMusicSliderPitch); +DEFFN(CMusicSliderSpeed); +DEFFN(CMusicSwitch); +DEFFN(CMusicSwitchInversion); +DEFFN(CMusicSwitchReverse); +DEFFN(CMusicVoiceMute); +DEFFN(CPetModeOff); +DEFFN(CPetModeOn); +DEFFN(CPetModePanel); +DEFFN(CPetPannel1); +DEFFN(CPetPannel2); +DEFFN(CPetPannel3); +DEFFN(CSendToSucc); +DEFFN(CSGTSelector); +DEFFN(CSliderButton); +DEFFN(CSmallChevLeftOff); +DEFFN(CSmallChevLeftOn); +DEFFN(CSmallChevRightOff); +DEFFN(CSmallChevRightOn); +DEFFN(CStatusChangeButton); +DEFFN(CSTButton); +DEFFN(CTextDown); +DEFFN(CTextSkrew); +DEFFN(CTextUp); +DEFFN(CToggleButton); +DEFFN(CToggleSwitch); + +DEFFN(CActMsg); +DEFFN(CActivationmsg); +DEFFN(CAddHeadPieceMsg); +DEFFN(CAnimateMaitreDMsg); +DEFFN(CArboretumGateMsg); +DEFFN(CArmPickedUpFromTableMsg); +DEFFN(CAutoSoundEvent); +DEFFN(CBilgeAutoSoundEvent); +DEFFN(CBilgeDispensorEvent); +DEFFN(CBodyInBilgeRoomMsg); +DEFFN(CBowlStateChange); +DEFFN(CCarryObjectArrivedMsg); +DEFFN(CChangeMusicMsg); +DEFFN(CChangeSeasonMsg); +DEFFN(CCheckAllPossibleCodes); +DEFFN(CCheckChevCode); +DEFFN(CChildDragEndMsg); +DEFFN(CChildDragMoveMsg); +DEFFN(CChildDragStartMsg); +DEFFN(CClearChevPanelBits); +DEFFN(CCorrectMusicPlayedMsg); +DEFFN(CCreateMusicPlayerMsg); +DEFFN(CCylinderHolderReadyMsg); +DEFFN(CDeactivationMsg); +DEFFN(CDeliverCCarryMsg); +DEFFN(CDisableMaitreDProdReceptor); +DEFFN(CDismissBotMsg); +DEFFN(CDoffNavHelmet); +DEFFN(CDonNavHelmet); +DEFFN(CDoorAutoSoundEvent); +DEFFN(CDoorbotNeededInElevatorMsg); +DEFFN(CDoorbotNeededInHomeMsg); +DEFFN(CDropObjectMsg); +DEFFN(CDropZoneGotObjectMsg); +DEFFN(CDropZoneLostObjectMsg); +DEFFN(CEditControlMsg); +DEFFN(CEnterNodeMsg); +DEFFN(CEnterRoomMsg); +DEFFN(CEnterViewMsg); +DEFFN(CEjectCylinderMsg); +DEFFN(CErasePhonographCylinderMsg); +DEFFN(CFrameMsg); +DEFFN(CFreshenCookieMsg); +DEFFN(CGetChevClassBits); +DEFFN(CGetChevClassNum); +DEFFN(CGetChevCodeFromRoomNameMsg); +DEFFN(CGetChevFloorBits); +DEFFN(CGetChevFloorNum); +DEFFN(CGetChevLiftBits); +DEFFN(CGetChevLiftNum); +DEFFN(CGetChevRoomBits); +DEFFN(CGetChevRoomNum); +DEFFN(CHoseConnectedMsg); +DEFFN(CInitializeAnimMsg); +DEFFN(CIsEarBowlPuzzleDone); +DEFFN(CIsHookedOnMsg); +DEFFN(CIsParrotPresentMsg); +DEFFN(CKeyCharMsg); +DEFFN(CLeaveNodeMsg); +DEFFN(CLeaveRoomMsg); +DEFFN(CLeaveViewMsg); +DEFFN(CLemonFallsFromTreeMsg); +DEFFN(CLightsMsg); +DEFFN(CLoadSuccessMsg); +DEFFN(CLockPhonographMsg); +DEFFN(CMaitreDDefeatedMsg); +DEFFN(CMaitreDHappyMsg); +DEFFN(CMessage); +DEFFN(CMissiveOMatActionMsg); +DEFFN(CMouseMsg); +DEFFN(CMouseMoveMsg); +DEFFN(CMouseButtonMsg); +DEFFN(CMouseButtonDownMsg); +DEFFN(CMouseButtonUpMsg); +DEFFN(CMouseDoubleClickMsg); +DEFFN(CMouseDragMsg); +DEFFN(CMouseDragStartMsg); +DEFFN(CMouseDragMoveMsg); +DEFFN(CMouseDragEndMsg); +DEFFN(CMoveToStartPosMsg); +DEFFN(CMovieEndMsg); +DEFFN(CMovieFrameMsg); +DEFFN(CMusicHasStartedMsg); +DEFFN(CMusicHasStoppedMsg); +DEFFN(CMusicSettingChangedMsg); +DEFFN(CNPCPlayAnimationMsg); +DEFFN(CNPCPlayIdleAnimationMsg); +DEFFN(CNPCPlayTalkingAnimationMsg); +DEFFN(CNPCQueueIdleAnimMsg); +DEFFN(CNutPuzzleMsg); +DEFFN(COnSummonBotMsg); +DEFFN(COpeningCreditsMsg); +DEFFN(CPETDeliverMsg); +DEFFN(CPETGainedObjectMsg); +DEFFN(CPETHelmetOnOffMsg); +DEFFN(CPETKeyboardOnOffMsg); +DEFFN(CPETLostObjectMsg); +DEFFN(CPETObjectSelectedMsg); +DEFFN(CPETObjectStateMsg); +DEFFN(CPETPhotoOnOffMsg); +DEFFN(CPETPlaySoundMsg); +DEFFN(CPETReceiveMsg); +DEFFN(CPETSetStarDestinationMsg); +DEFFN(CPETStarFieldLockMsg); +DEFFN(CPETStereoFieldOnOffMsg); +DEFFN(CPETTargetMsg); +DEFFN(CPETUpMsg); +DEFFN(CPETDownMsg); +DEFFN(CPETLeftMsg); +DEFFN(CPETRightMsg); +DEFFN(CPETActivateMsg); +DEFFN(CPanningAwayFromParrotMsg); +DEFFN(CParrotSpeakMsg); +DEFFN(CParrotTriesChickenMsg); +DEFFN(CPassOnDragStartMsg); +DEFFN(CPhonographPlayMsg); +DEFFN(CPhonographReadyToPlayMsg); +DEFFN(CPhonographRecordMsg); +DEFFN(CPhonographStopMsg); +DEFFN(CPlayRangeMsg); +DEFFN(CPlayerTriesRestaurantTableMsg); +DEFFN(CPreEnterNodeMsg); +DEFFN(CPreEnterRoomMsg); +DEFFN(CPreEnterViewMsg); +DEFFN(CPreSaveMsg); +DEFFN(CProdMaitreDMsg); +DEFFN(CPumpingMsg); +DEFFN(CPutBotBackInHisBoxMsg); +DEFFN(CPutParrotBackMsg); +DEFFN(CPuzzleSolvedMsg); +DEFFN(CQueryCylinderHolderMsg); +DEFFN(CQueryCylinderMsg); +DEFFN(CQueryCylinderNameMsg); +DEFFN(CQueryCylinderTypeMsg); +DEFFN(CQueryMusicControlSettingMsg); +DEFFN(CQueryPhonographState); +DEFFN(CRecordOntoCylinderMsg); +DEFFN(CRemoveFromGameMsg); +DEFFN(CReplaceBowlAndNutsMsg); +DEFFN(CRestaurantMusicChanged); +DEFFN(CSendCCarryMsg); +DEFFN(CSenseWorkingMsg); +DEFFN(CServiceElevatorDoor); +DEFFN(CServiceElevatorFloorChangeMsg); +DEFFN(CServiceElevatorFloorRequestMsg); +DEFFN(CServiceElevatorMsg); +DEFFN(CSetChevButtonImageMsg); +DEFFN(CSetChevClassBits); +DEFFN(CSetChevFloorBits); +DEFFN(CSetChevLiftBits); +DEFFN(CSetChevPanelBitMsg); +DEFFN(CSetChevPanelButtonsMsg); +DEFFN(CSetChevRoomBits); +DEFFN(CSetFrameMsg); +DEFFN(CSetMusicControlsMsg); +DEFFN(CSetVarMsg); +DEFFN(CSetVolumeMsg); +DEFFN(CShipSettingMsg); +DEFFN(CShowTextMsg); +DEFFN(CSignalObject); +DEFFN(CSpeechFallsFromTreeMsg); +DEFFN(CStartMusicMsg); +DEFFN(CStatusChangeMsg); +DEFFN(CStopMusicMsg); +DEFFN(CSubAcceptCCarryMsg); +DEFFN(CSubDeliverCCarryMsg); +DEFFN(CSubSendCCarryMsg); +DEFFN(CSUBTransition); +DEFFN(CSubTurnOffMsg); +DEFFN(CSubTurnOnMsg); +DEFFN(CSummonBotMsg); +DEFFN(CSummonBotQueryMsg); +DEFFN(CTakeHeadPieceMsg); +DEFFN(CTextInputMsg); +DEFFN(CTimeDilationMsg); +DEFFN(CTimeMsg); +DEFFN(CTimerMsg); +DEFFN(CTitleSequenceEndedMsg); +DEFFN(CTransitMsg); +DEFFN(CTranslateObjectMsg); +DEFFN(CTransportMsg); +DEFFN(CTriggerAutoMusicPlayerMsg); +DEFFN(CTriggerNPCEvent); +DEFFN(CTrueTalkGetAnimSetMsg); +DEFFN(CTrueTalkGetAssetDetailsMsg); +DEFFN(CTrueTalkGetStateValueMsg); +DEFFN(CTrueTalkNotifySpeechEndedMsg); +DEFFN(CTrueTalkNotifySpeechStartedMsg); +DEFFN(CTrueTalkQueueUpAnimSetMsg); +DEFFN(CTrueTalkSelfQueueAnimSetMsg); +DEFFN(CTrueTalkTriggerActionMsg); +DEFFN(CTurnOff); +DEFFN(CTurnOn); +DEFFN(CUse); +DEFFN(CUseWithCharMsg); +DEFFN(CUseWithOtherMsg); +DEFFN(CVirtualKeyCharMsg); +DEFFN(CVisibleMsg); + +DEFFN(CEnterBombRoom); +DEFFN(CEnterBridge); +DEFFN(CEnterExitFirstClassState); +DEFFN(CEnterExitMiniLift); +DEFFN(CEnterExitSecClassMiniLift); +DEFFN(CEnterExitView); +DEFFN(CEnterSecClassState); +DEFFN(CExitArboretum); +DEFFN(CExitBridge); +DEFFN(CExitLift); +DEFFN(CExitPellerator); +DEFFN(CExitStateRoom); +DEFFN(CExitTiania); +DEFFN(CMovePlayerInParrotRoom); +DEFFN(CMovePlayerTo); +DEFFN(CMovePlayerToFrom); +DEFFN(CMultiMove); +DEFFN(CPanFromPel); +DEFFN(CRestaurantPanHandler); +DEFFN(CScraliontisTable); +DEFFN(CRestrictedMove); +DEFFN(CTripDownCanal); + +DEFFN(CBarbot); +DEFFN(CBellBot); +DEFFN(CCallBot); +DEFFN(CCharacter); +DEFFN(CDeskbot); +DEFFN(CDoorbot); +DEFFN(CLiftBot); +DEFFN(CMaitreD); +DEFFN(CMobile); +DEFFN(CParrot); +DEFFN(CRobotController); +DEFFN(CStarlings); +DEFFN(CSummonBots); +DEFFN(CSuccUBus); +DEFFN(CTitania); +DEFFN(CTrueTalkNPC); +DEFFN(CAutoMusicPlayer); +DEFFN(CAutoMusicPlayerBase); +DEFFN(CAutoSoundPlayer); +DEFFN(CAutoSoundPlayerADSR); +DEFFN(CBackgroundSoundMaker); +DEFFN(CBirdSong); +DEFFN(CDomeFromTopOfWell); +DEFFN(CEnterViewTogglesOtherMusic); +DEFFN(CGondolierSong); +DEFFN(CMusicPlayer); +DEFFN(CNodeAutoSoundPlayer); +DEFFN(CRestrictedAutoMusicPlayer); +DEFFN(CRoomAutoSoundPlayer); +DEFFN(CRoomTriggerAutoMusicPlayer); +DEFFN(CSeasonNoises); +DEFFN(CSeasonalMusicPlayer); +DEFFN(CTitaniaSpeech); +DEFFN(CTriggerAutoMusicPlayer); +DEFFN(CViewAutoSoundPlayer); +DEFFN(CViewTogglesOtherMusic); +DEFFN(CWaterLappingSounds); +DEFFN(CStarControl); +DEFFN(CTimeEventInfo); + +void CSaveableObject::initClassList() { + _classDefs = new Common::List<ClassDef *>(); + _classList = new Common::HashMap<Common::String, CreateFunction>(); + ADDFN(CArm, CCarry); + ADDFN(CAuditoryCentre, CBrain); + ADDFN(CBowlEar, CEar); + ADDFN(CBrain, CCarry); + ADDFN(CBridgePiece, CCarry); + ADDFN(CCarry, CGameObject); + ADDFN(CCarryParrot, CCarry); + ADDFN(CCentralCore, CBrain); + ADDFN(CChicken, CCarry); + ADDFN(CCrushedTV, CCarry); + ADDFN(CEar, CHeadPiece); + ADDFN(CEye, CHeadPiece); + ADDFN(CFeathers, CCarry); + ADDFN(CFruit, CCarry); + ADDFN(CGlass, CCarry); + ADDFN(CHammer, CCarry); + ADDFN(CHeadPiece, CCarry); + ADDFN(CHose, CCarry); + ADDFN(CHoseEnd, CHose); + ADDFN(CKey, CCarry); + ADDFN(CLiftbotHead, CCarry); + ADDFN(CLongStick, CCarry); + ADDFN(CMagazine, CCarry); + ADDFN(CMaitreDLeftArm, CArm); + ADDFN(CMaitreDRightArm, CArm); + ADDFN(CMouth, CHeadPiece); + ADDFN(CNapkin, CCarry); + ADDFN(CNose, CHeadPiece); + ADDFN(CNote, CCarry); + ADDFN(CParcel, CCarry); + ADDFN(CPerch, CCentralCore); + ADDFN(CPhonographCylinder, CCarry); + ADDFN(CPhonographEar, CEar); + ADDFN(CPhotograph, CCarry); + ADDFN(CPlugIn, CCarry); + ADDFN(CSpeechCentre, CBrain); + ADDFN(CSweets, CCarry); + ADDFN(CVisionCentre, CBrain); + + ADDFN(CBackground, CGameObject); + ADDFN(CClickResponder, CGameObject); + ADDFN(CDontSaveFileItem, CFileItem); + ADDFN(CDropTarget, CGameObject); + ADDFN(CFileItem, CTreeItem); + ADDFN(CFileListItem, ListItem); + ADDFN(CGameObject, CNamedItem); + ADDFN(CGameObjectDescItem, CTreeItem); + ADDFN(CLinkItem, CNamedItem); + ADDFN(ListItem, CSaveableObject); + ADDFN(CMessageTarget, CSaveableObject); + ADDFN(CMailMan, CGameObject); + ADDFN(CMovieClip, ListItem); + ADDFN(CMultiDropTarget, CDropTarget); + ADDFN(CNamedItem, CTreeItem); + ADDFN(CNodeItem, CNamedItem); + ADDFN(CProjectItem, CFileItem); + ADDFN(CResourceKey, CSaveableObject); + ADDFN(CRoomItem, CNamedItem); + ADDFN(CSaveableObject, CSaveableObject); + ADDFN(CStaticImage, CGameObject); + ADDFN(CTurnOnObject, CBackground); + ADDFN(CTreeItem, CMessageTarget); + ADDFN(CTurnOnPlaySound, CTurnOnObject); + ADDFN(CTurnOnTurnOff, CBackground); + ADDFN(CViewItem, CNamedItem); + + ADDFN(CAnnounce, CGameObject); + ADDFN(CAnnoyBarbot, CGameObject); + ADDFN(CArbBackground, CBackground); + ADDFN(CArboretumGate, CBackground); + ADDFN(CAutoAnimate, CBackground); + ADDFN(CBarBell, CGameObject); + ADDFN(CBarMenu, CGameObject); + ADDFN(CBarMenuButton, CGameObject); + ADDFN(CBelbotGetLight, CGameObject); + ADDFN(CBilgeSuccUBus, CSuccUBus); + ADDFN(CBomb, CBackground); + ADDFN(CBottomOfWellMonitor, CGameObject); + ADDFN(CBowlUnlocker, CGameObject); + ADDFN(CBrainSlot, CGameObject); + ADDFN(CBridgeDoor, CGameObject); + ADDFN(CBridgeView, CBackground); + ADDFN(CBrokenPellBase, CBackground); + ADDFN(CBrokenPellerator, CBrokenPellBase); + ADDFN(CBrokenPelleratorFroz, CBrokenPellBase); + ADDFN(CCage, CBackground); + ADDFN(CCallPellerator, CGameObject); + ADDFN(CCaptainsWheel, CBackground); + ADDFN(CCDROM, CGameObject); + ADDFN(CCDROMComputer, CGameObject); + ADDFN(CCDROMTray, CGameObject); + ADDFN(CCellPointButton, CBackground); + ADDFN(CChevCode, CGameObject); + ADDFN(CChevPanel, CGameObject); + ADDFN(CChickenCooler, CGameObject); + ADDFN(CChickenDispensor, CBackground); + ADDFN(CodeWheel, CBomb); + ADDFN(CCloseBrokenPel, CBackground); + ADDFN(CComputer, CBackground); + ADDFN(CComputerScreen, CGameObject); + ADDFN(CCookie, CGameObject); + ADDFN(CCredits, CGameObject); + ADDFN(CCreditsButton, CBackground); + ADDFN(CDeadArea, CGameObject); + ADDFN(CDeskClickResponder, CClickResponder); + ADDFN(CDoorbotElevatorHandler, CGameObject); + ADDFN(CDoorbotHomeHandler, CGameObject); + ADDFN(CDropTarget, CGameObject); + ADDFN(CEarSweetBowl, CSweetBowl); + ADDFN(CEjectPhonographButton, CBackground); + ADDFN(CElevatorActionArea, CGameObject); + ADDFN(CEmmaControl, CBackground); + ADDFN(CEmptyNutBowl, CGameObject); + ADDFN(CEndCreditText, CGameObject); + ADDFN(CEndCredits, CGameObject); + ADDFN(CEndExplodeShip, CGameObject); + ADDFN(CEndGameCredits, CGameObject); + ADDFN(CEndSequenceControl, CGameObject); + ADDFN(CFan, CGameObject); + ADDFN(CFanControl, CGameObject); + ADDFN(CFanDecrease, CGameObject); + ADDFN(CFanIncrease, CGameObject); + ADDFN(CFanNoises, CGameObject); + ADDFN(CFloorIndicator, CGameObject); + ADDFN(CGamesConsole, CBackground); + ADDFN(CGetLiftEye2, CGameObject); + ADDFN(CGlassSmasher, CGameObject); + ADDFN(CHammerClip, CGameObject); + ADDFN(CHammerDispensor, CBackground); + ADDFN(CHammerDispensorButton, CStartAction); + ADDFN(CHeadSlot, CGameObject); + ADDFN(CHeadSmashEvent, CBackground); + ADDFN(CHeadSmashLever, CBackground); + ADDFN(CHeadSpinner, CGameObject); + ADDFN(CIdleSummoner, CGameObject); + ADDFN(CLeaveSecClassState, CGameObject); + ADDFN(CLemonDispensor, CBackground); + ADDFN(CLight, CBackground); + ADDFN(CLightSwitch, CBackground); + ADDFN(CLittleLiftButton, CBackground); + ADDFN(CLongStickDispenser, CGameObject); + ADDFN(CMissiveOMat, CGameObject); + ADDFN(CMissiveOMatButton, CEditControl); + ADDFN(CMovieTester, CGameObject); + ADDFN(CMusicalInstrument, CBackground); + ADDFN(CMusicConsoleButton, CMusicPlayer); + ADDFN(CMusicRoomPhonograph, CRestaurantPhonograph); + ADDFN(CMusicRoomStopPhonographButton, CEjectPhonographButton); + ADDFN(CMusicSystemLock, CDropTarget); + ADDFN(CNavHelmet, CGameObject); + ADDFN(CNavigationComputer, CGameObject); + ADDFN(CNoNutBowl, CBackground); + ADDFN(CNoseHolder, CDropTarget); + ADDFN(CNullPortHole, CClickResponder); + ADDFN(CNutReplacer, CGameObject); + ADDFN(CPetDisabler, CGameObject); + ADDFN(CPhonograph, CMusicPlayer); + ADDFN(CPhonographLid, CGameObject); + ADDFN(CPlayMusicButton, CBackground); + ADDFN(CPlayOnAct, CBackground); + ADDFN(CPortHole, CGameObject); + ADDFN(CRecordPhonographButton, CBackground); + ADDFN(CReplacementEar, CBackground); + ADDFN(CReservedTable, CGameObject); + ADDFN(CRestaurantCylinderHolder, CDropTarget); + ADDFN(CRestaurantPhonograph, CPhonograph); + ADDFN(CSauceDispensor, CBackground); + ADDFN(CSearchPoint, CGameObject); + ADDFN(CSeasonBackground, CBackground); + ADDFN(CSeasonBarrel, CBackground); + ADDFN(CSeasonalAdjustment, CBackground); + ADDFN(CServiceElevatorWindow, CBackground); + ADDFN(CShipSetting, CBackground); + ADDFN(CShipSettingButton, CGameObject); + ADDFN(CShowCellpoints, CGameObject); + ADDFN(CSpeechDispensor, CBackground); + ADDFN(CSplashAnimation, CGameObject); + ADDFN(CStarlingPuret, CGameObject); + ADDFN(CStartAction, CBackground); + ADDFN(CStopPhonographButton, CBackground); + ADDFN(CSUBGlass, CGameObject); + ADDFN(CSUBWrapper, CGameObject); + ADDFN(CSweetBowl, CGameObject); + ADDFN(CTelevision, CBackground); + ADDFN(CThirdClassCanal, CBackground); + ADDFN(CThrowTVDownWell, CGameObject); + ADDFN(CTitaniaStillControl, CGameObject); + ADDFN(CTOWParrotNav, CGameObject); + ADDFN(CUpLighter, CDropTarget); + ADDFN(CUselessLever, CToggleButton); + ADDFN(CVolumeControl, CGameObject); + ADDFN(CWheelButton, CBackground); + ADDFN(CWheelHotSpot, CBackground); + ADDFN(CWheelSpin, CBackground); + ADDFN(CWheelSpinHorn, CWheelSpin); + ADDFN(CGondolierBase, CGameObject); + ADDFN(CGondolierChest, CGondolierBase); + ADDFN(CGondolierFace, CGondolierBase); + ADDFN(CGondolierMixer, CGondolierBase); + ADDFN(CGondolierSlider, CGondolierBase); + ADDFN(CMaitreDArmHolder, CDropTarget); + ADDFN(CMaitreDBody, CMaitreDProdReceptor); + ADDFN(CMaitreDLegs, CMaitreDProdReceptor); + ADDFN(CMaitreDProdReceptor, CGameObject); + ADDFN(CParrotLobbyController, CParrotLobbyObject); + ADDFN(CParrotLobbyLinkUpdater, CParrotLobbyObject); + ADDFN(CParrotLobbyObject, CGameObject); + ADDFN(CParrotLobbyViewObject, CParrotLobbyObject); + ADDFN(CParrotLoser, CGameObject); + ADDFN(CParrotNutBowlActor, CGameObject); + ADDFN(CParrotNutEater, CGameObject); + ADDFN(CParrotPerchHolder, CMultiDropTarget); + ADDFN(CParrotSuccUBus, CSuccUBus); + ADDFN(CParrotTrigger, CGameObject); + ADDFN(CPlayerMeetsParrot, CGameObject); + ADDFN(CPET, CGameObject); + ADDFN(CPETClass1, CGameObject); + ADDFN(CPETClass2, CGameObject); + ADDFN(CPETClass3, CGameObject); + ADDFN(CPETLift, CPETTransport); + ADDFN(CPETMonitor, CGameObject); + ADDFN(CPETPellerator, CPETTransport); + ADDFN(CPETPosition, CGameObject); + ADDFN(CPETSentinal, CGameObject); + ADDFN(CPETSounds, CGameObject); + ADDFN(CPETTransition, CGameObject); + ADDFN(CPETTransport, CGameObject); + ADDFN(CPickUp, CGameObject); + ADDFN(CPickUpBarGlass, CPickUp); + ADDFN(CPickUpHose, CPickUp); + ADDFN(CPickUpLemon, CPickUp); + ADDFN(CPickUpSpeechCentre, CPickUp); + ADDFN(CPickUpVisCentre, CPickUp); + ADDFN(CBarShelfVisCentre, CPlaceHolderItem); + ADDFN(CLemonOnBar, CPlaceHolderItem); + ADDFN(CPlaceHolderItem, CGameObject); + ADDFN(CTVOnBar, CPlaceHolderItem); + ADDFN(CArmchair, CSGTStateRoom); + ADDFN(CBasin, CSGTStateRoom); + ADDFN(CBedfoot, CSGTStateRoom); + ADDFN(CBedhead, CSGTStateRoom); + ADDFN(CChestOfDrawers, CSGTStateRoom); + ADDFN(CDesk, CSGTStateRoom); + ADDFN(CDeskchair, CSGTStateRoom); + ADDFN(CDrawer, CSGTStateRoom); + ADDFN(CSGTDoors, CGameObject); + ADDFN(SGTNav, CSGTStateRoom); + ADDFN(CSGTNavigation, CGameObject); + ADDFN(CSGTRestaurantDoors, CGameObject); + ADDFN(CSGTStateControl, CBackground); + ADDFN(CSGTStateRoom, CBackground); + ADDFN(CSGTTV, CSGTStateRoom); + ADDFN(CSGTUpperDoorsSound, CClickResponder); + ADDFN(CToilet, CSGTStateRoom); + ADDFN(CVase, CSGTStateRoom); + ADDFN(CWashstand, CSGTStateRoom); + + ADDFN(CGondolier, CTransport); + ADDFN(CLift, CTransport); + ADDFN(CLiftindicator, CLift); + ADDFN(CPellerator, CTransport); + ADDFN(CServiceElevator, CTransport); + ADDFN(CTransport, CMobile); + + ADDFN(CActButton, CSTButton); + ADDFN(CChangesSeasonButton, CSTButton); + ADDFN(CChevLeftOff, CToggleSwitch); + ADDFN(CChevLeftOn, CToggleSwitch); + ADDFN(CChevRightOff, CToggleSwitch); + ADDFN(CChevRightOn, CToggleSwitch); + ADDFN(CChevSendRecSwitch, CToggleSwitch); + ADDFN(CChevSwitch, CToggleSwitch); + ADDFN(CEditControl, CGameObject); + ADDFN(CElevatorButton, CSTButton); + ADDFN(CGetFromSucc, CToggleSwitch); + ADDFN(CHelmetOnOff, CToggleSwitch); + ADDFN(CHomePhoto, CToggleSwitch); + ADDFN(CIconNavAction, CToggleSwitch); + ADDFN(CIconNavButt, CPetGraphic); + ADDFN(CIconNavDown, CToggleSwitch); + ADDFN(CIconNavImage, CPetGraphic); + ADDFN(CIconNavLeft, CToggleSwitch); + ADDFN(CIconNavReceive, CPetGraphic); + ADDFN(CIconNavRight, CToggleSwitch); + ADDFN(CIconNavSend, CPetGraphic); + ADDFN(CIconNavUp, CToggleSwitch); + ADDFN(CKeybrdButt, CToggleSwitch); + ADDFN(CMoveObjectButton, CSTButton); + ADDFN(CMusicControl, CBackground); + ADDFN(CMusicSlider, CMusicControl); + ADDFN(CMusicSliderPitch, CMusicSlider); + ADDFN(CMusicSliderSpeed, CMusicSlider); + ADDFN(CMusicSwitch, CMusicControl); + ADDFN(CMusicSwitchInversion, CMusicSwitch); + ADDFN(CMusicSwitchReverse, CMusicSwitch); + ADDFN(CMusicVoiceMute, CMusicControl); + ADDFN(CPetControl, CGameObject); + ADDFN(CPetDragChev, CPetGraphic2); + ADDFN(CPetGraphic, CGameObject); + ADDFN(CPetGraphic2, CGameObject); + ADDFN(PETLeaf, CGameObject); + ADDFN(CPetModeOff, CToggleSwitch); + ADDFN(CPetModeOn, CToggleSwitch); + ADDFN(CPetModePanel, CToggleSwitch); + ADDFN(CPetPannel1, CPetGraphic); + ADDFN(CPetPannel2, CPetGraphic); + ADDFN(CPetPannel3, CPetGraphic); + ADDFN(CSendToSucc, CToggleSwitch); + ADDFN(CSGTSelector, CPetGraphic); + ADDFN(CSliderButton, CSTButton); + ADDFN(CSmallChevLeftOff, CToggleSwitch); + ADDFN(CSmallChevLeftOn, CToggleSwitch); + ADDFN(CSmallChevRightOff, CToggleSwitch); + ADDFN(CSmallChevRightOn, CToggleSwitch); + ADDFN(CStatusChangeButton, CSTButton); + ADDFN(CSTButton, CBackground); + ADDFN(CTextDown, CPetGraphic); + ADDFN(CTextSkrew, CPetGraphic); + ADDFN(CTextUp, CPetGraphic); + ADDFN(CToggleButton, CBackground); + ADDFN(CToggleSwitch, CGameObject); + + ADDFN(CActMsg, CMessage); + ADDFN(CActivationmsg, CMessage); + ADDFN(CAddHeadPieceMsg, CMessage); + ADDFN(CAnimateMaitreDMsg, CMessage); + ADDFN(CArboretumGateMsg, CMessage); + ADDFN(CArmPickedUpFromTableMsg, CMessage); + ADDFN(CAutoSoundEvent, CGameObject); + ADDFN(CBilgeAutoSoundEvent, CAutoSoundEvent); + ADDFN(CBilgeDispensorEvent, CAutoSoundEvent); + ADDFN(CBodyInBilgeRoomMsg, CMessage); + ADDFN(CBowlStateChange, CMessage); + ADDFN(CCarryObjectArrivedMsg, CMessage); + ADDFN(CChangeMusicMsg, CMessage); + ADDFN(CChangeSeasonMsg, CMessage); + ADDFN(CCheckAllPossibleCodes, CMessage); + ADDFN(CCheckChevCode, CMessage); + ADDFN(CChildDragEndMsg, CMessage); + ADDFN(CChildDragMoveMsg, CMessage); + ADDFN(CChildDragStartMsg, CMessage); + ADDFN(CClearChevPanelBits, CMessage); + ADDFN(CCorrectMusicPlayedMsg, CMessage); + ADDFN(CCreateMusicPlayerMsg, CMessage); + ADDFN(CCylinderHolderReadyMsg, CMessage); + ADDFN(CDeactivationMsg, CMessage); + ADDFN(CDeliverCCarryMsg, CMessage); + ADDFN(CDisableMaitreDProdReceptor, CMessage); + ADDFN(CDismissBotMsg, CMessage); + ADDFN(CDoffNavHelmet, CMessage); + ADDFN(CDonNavHelmet, CMessage); + ADDFN(CDoorAutoSoundEvent, CAutoSoundEvent); + ADDFN(CDoorbotNeededInElevatorMsg, CMessage); + ADDFN(CDoorbotNeededInHomeMsg, CMessage); + ADDFN(CDropObjectMsg, CMessage); + ADDFN(CDropZoneGotObjectMsg, CMessage); + ADDFN(CDropZoneLostObjectMsg, CMessage); + ADDFN(CEditControlMsg, CMessage); + ADDFN(CEnterNodeMsg, CMessage); + ADDFN(CEnterRoomMsg, CMessage); + ADDFN(CEnterViewMsg, CMessage); + ADDFN(CEjectCylinderMsg, CMessage); + ADDFN(CErasePhonographCylinderMsg, CMessage); + ADDFN(CFrameMsg, CMessage); + ADDFN(CFreshenCookieMsg, CMessage); + ADDFN(CGetChevClassBits, CMessage); + ADDFN(CGetChevClassNum, CMessage); + ADDFN(CGetChevCodeFromRoomNameMsg, CMessage); + ADDFN(CGetChevFloorBits, CMessage); + ADDFN(CGetChevFloorNum, CMessage); + ADDFN(CGetChevLiftBits, CMessage); + ADDFN(CGetChevLiftNum, CMessage); + ADDFN(CGetChevRoomBits, CMessage); + ADDFN(CGetChevRoomNum, CMessage); + ADDFN(CHoseConnectedMsg, CMessage); + ADDFN(CInitializeAnimMsg, CMessage); + ADDFN(CIsEarBowlPuzzleDone, CMessage); + ADDFN(CIsHookedOnMsg, CMessage); + ADDFN(CIsParrotPresentMsg, CMessage); + ADDFN(CKeyCharMsg, CMessage); + ADDFN(CLeaveNodeMsg, CMessage); + ADDFN(CLeaveRoomMsg, CMessage); + ADDFN(CLeaveViewMsg, CMessage); + ADDFN(CLemonFallsFromTreeMsg, CMessage); + ADDFN(CLightsMsg, CMessage); + ADDFN(CLoadSuccessMsg, CMessage); + ADDFN(CLockPhonographMsg, CMessage); + ADDFN(CMaitreDDefeatedMsg, CMessage); + ADDFN(CMaitreDHappyMsg, CMessage); + ADDFN(CMessage, CSaveableObject); + ADDFN(CMissiveOMatActionMsg, CMessage); + ADDFN(CMouseMsg, CMessage); + ADDFN(CMouseMoveMsg, CMouseMsg); + ADDFN(CMouseButtonMsg, CMouseMsg); + ADDFN(CMouseButtonDownMsg, CMouseButtonMsg); + ADDFN(CMouseButtonUpMsg, CMouseButtonMsg); + ADDFN(CMouseDoubleClickMsg, CMouseButtonMsg); + ADDFN(CMouseDragMsg, CMouseMsg); + ADDFN(CMouseDragStartMsg, CMouseDragMsg); + ADDFN(CMouseDragMoveMsg, CMouseDragMsg); + ADDFN(CMouseDragEndMsg, CMouseDragMsg); + ADDFN(CMoveToStartPosMsg, CMessage); + ADDFN(CMovieEndMsg, CMessage); + ADDFN(CMovieFrameMsg, CMessage); + ADDFN(CMusicHasStartedMsg, CMessage); + ADDFN(CMusicHasStoppedMsg, CMessage); + ADDFN(CMusicSettingChangedMsg, CMessage); + ADDFN(CNPCPlayAnimationMsg, CMessage); + ADDFN(CNPCPlayIdleAnimationMsg, CMessage); + ADDFN(CNPCPlayTalkingAnimationMsg, CMessage); + ADDFN(CNPCQueueIdleAnimMsg, CMessage); + ADDFN(CNutPuzzleMsg, CMessage); + ADDFN(COnSummonBotMsg, CMessage); + ADDFN(COpeningCreditsMsg, CMessage); + ADDFN(CPETDeliverMsg, CMessage); + ADDFN(CPETGainedObjectMsg, CMessage); + ADDFN(CPETHelmetOnOffMsg, CMessage); + ADDFN(CPETKeyboardOnOffMsg, CMessage); + ADDFN(CPETLostObjectMsg, CMessage); + ADDFN(CPETObjectSelectedMsg, CMessage); + ADDFN(CPETObjectStateMsg, CMessage); + ADDFN(CPETPhotoOnOffMsg, CMessage); + ADDFN(CPETPlaySoundMsg, CMessage); + ADDFN(CPETReceiveMsg, CMessage); + ADDFN(CPETSetStarDestinationMsg, CMessage); + ADDFN(CPETStarFieldLockMsg, CMessage); + ADDFN(CPETStereoFieldOnOffMsg, CMessage); + ADDFN(CPETTargetMsg, CMessage); + ADDFN(CPETUpMsg, CPETTargetMsg); + ADDFN(CPETDownMsg, CPETTargetMsg); + ADDFN(CPETLeftMsg, CPETTargetMsg); + ADDFN(CPETRightMsg, CPETTargetMsg); + ADDFN(CPETActivateMsg, CPETTargetMsg); + ADDFN(CPanningAwayFromParrotMsg, CMessage); + ADDFN(CParrotSpeakMsg, CMessage); + ADDFN(CParrotTriesChickenMsg, CMessage); + ADDFN(CPassOnDragStartMsg, CMessage); + ADDFN(CPhonographPlayMsg, CMessage); + ADDFN(CPhonographReadyToPlayMsg, CMessage); + ADDFN(CPhonographRecordMsg, CMessage); + ADDFN(CPhonographStopMsg, CMessage); + ADDFN(CPlayRangeMsg, CMessage); + ADDFN(CPlayerTriesRestaurantTableMsg, CMessage); + ADDFN(CEnterNodeMsg, CMessage); + ADDFN(CEnterRoomMsg, CMessage); + ADDFN(CEnterViewMsg, CMessage); + ADDFN(CPreSaveMsg, CMessage); + ADDFN(CProdMaitreDMsg, CMessage); + ADDFN(CPumpingMsg, CMessage); + ADDFN(CPutBotBackInHisBoxMsg, CMessage); + ADDFN(CPutParrotBackMsg, CMessage); + ADDFN(CPuzzleSolvedMsg, CMessage); + ADDFN(CQueryCylinderHolderMsg, CMessage); + ADDFN(CQueryCylinderMsg, CMessage); + ADDFN(CQueryCylinderNameMsg, CMessage); + ADDFN(CQueryCylinderTypeMsg, CMessage); + ADDFN(CQueryMusicControlSettingMsg, CMessage); + ADDFN(CQueryPhonographState, CMessage); + ADDFN(CRecordOntoCylinderMsg, CMessage); + ADDFN(CRemoveFromGameMsg, CMessage); + ADDFN(CReplaceBowlAndNutsMsg, CMessage); + ADDFN(CRestaurantMusicChanged, CMessage); + ADDFN(CSendCCarryMsg, CMessage); + ADDFN(CSenseWorkingMsg, CMessage); + ADDFN(CServiceElevatorDoor, CMessage); + ADDFN(CServiceElevatorFloorChangeMsg, CMessage); + ADDFN(CServiceElevatorFloorRequestMsg, CMessage); + ADDFN(CServiceElevatorMsg, CMessage); + ADDFN(CSetChevButtonImageMsg, CMessage); + ADDFN(CSetChevClassBits, CMessage); + ADDFN(CSetChevFloorBits, CMessage); + ADDFN(CSetChevLiftBits, CMessage); + ADDFN(CSetChevPanelBitMsg, CMessage); + ADDFN(CSetChevPanelButtonsMsg, CMessage); + ADDFN(CSetChevRoomBits, CMessage); + ADDFN(CSetFrameMsg, CMessage); + ADDFN(CSetMusicControlsMsg, CMessage); + ADDFN(CSetVarMsg, CMessage); + ADDFN(CSetVolumeMsg, CMessage); + ADDFN(CShipSettingMsg, CMessage); + ADDFN(CShowTextMsg, CMessage); + ADDFN(CSignalObject, CMessage); + ADDFN(CSpeechFallsFromTreeMsg, CMessage); + ADDFN(CStartMusicMsg, CMessage); + ADDFN(CStatusChangeMsg, CMessage); + ADDFN(CStopMusicMsg, CMessage); + ADDFN(CSubAcceptCCarryMsg, CMessage); + ADDFN(CSubDeliverCCarryMsg, CMessage); + ADDFN(CSubSendCCarryMsg, CMessage); + ADDFN(CSUBTransition, CMessage); + ADDFN(CSubTurnOffMsg, CMessage); + ADDFN(CSubTurnOnMsg, CMessage); + ADDFN(CSummonBotMsg, CMessage); + ADDFN(CSummonBotQueryMsg, CMessage); + ADDFN(CTakeHeadPieceMsg, CMessage); + ADDFN(CTextInputMsg, CMessage); + ADDFN(CTimeDilationMsg, CMessage); + ADDFN(CTimeMsg, CMessage); + ADDFN(CTimerMsg, CTimeMsg); + ADDFN(CTitleSequenceEndedMsg, CMessage); + ADDFN(CTransitMsg, CMessage); + ADDFN(CTranslateObjectMsg, CMessage); + ADDFN(CTransportMsg, CMessage); + ADDFN(CTriggerAutoMusicPlayerMsg, CMessage); + ADDFN(CTriggerNPCEvent, CMessage); + ADDFN(CTrueTalkGetAnimSetMsg, CMessage); + ADDFN(CTrueTalkGetAssetDetailsMsg, CMessage); + ADDFN(CTrueTalkGetStateValueMsg, CMessage); + ADDFN(CTrueTalkNotifySpeechEndedMsg, CMessage); + ADDFN(CTrueTalkNotifySpeechStartedMsg, CMessage); + ADDFN(CTrueTalkQueueUpAnimSetMsg, CMessage); + ADDFN(CTrueTalkSelfQueueAnimSetMsg, CMessage); + ADDFN(CTrueTalkTriggerActionMsg, CMessage); + ADDFN(CTurnOff, CMessage); + ADDFN(CTurnOn, CMessage); + ADDFN(CUse, CMessage); + ADDFN(CUseWithCharMsg, CMessage); + ADDFN(CUseWithOtherMsg, CMessage); + ADDFN(CVirtualKeyCharMsg, CMessage); + ADDFN(CVisibleMsg, CMessage); + + ADDFN(CEnterBombRoom, CMovePlayerTo); + ADDFN(CEnterBridge, CGameObject); + ADDFN(CEnterExitFirstClassState, CGameObject); + ADDFN(CEnterExitMiniLift, CSGTNavigation); + ADDFN(CEnterExitSecClassMiniLift, CGameObject); + ADDFN(CEnterExitView, CGameObject); + ADDFN(CEnterSecClassState, CGameObject); + ADDFN(CExitArboretum, CMovePlayerTo); + ADDFN(CExitBridge, CMovePlayerTo); + ADDFN(CExitLift, CGameObject); + ADDFN(CExitPellerator, CGameObject); + ADDFN(CExitStateRoom, CMovePlayerTo); + ADDFN(CExitTiania, CMovePlayerTo); + ADDFN(CMovePlayerInParrotRoom, CMovePlayerTo); + ADDFN(CMovePlayerTo, CGameObject); + ADDFN(CMovePlayerToFrom, CGameObject); + ADDFN(CMultiMove, CMovePlayerTo); + ADDFN(CPanFromPel, CMovePlayerTo); + ADDFN(CRestaurantPanHandler, CMovePlayerTo); + ADDFN(CScraliontisTable, CRestaurantPanHandler); + ADDFN(CRestrictedMove, CMovePlayerTo); + ADDFN(CTripDownCanal, CMovePlayerTo); + + ADDFN(CBarbot, CTrueTalkNPC); + ADDFN(CBellBot, CTrueTalkNPC); + ADDFN(CCallBot, CGameObject); + ADDFN(CCharacter, CGameObject); + ADDFN(CDeskbot, CTrueTalkNPC); + ADDFN(CDoorbot, CTrueTalkNPC); + ADDFN(CMaitreD, CTrueTalkNPC); + ADDFN(CLiftBot, CTrueTalkNPC); + ADDFN(CMobile, CCharacter); + ADDFN(CParrot, CTrueTalkNPC); + ADDFN(CRobotController, CGameObject); + ADDFN(CStarlings, CCharacter); + ADDFN(CSuccUBus, CTrueTalkNPC); + ADDFN(CSummonBots, CRobotController); + ADDFN(CTitania, CCharacter); + ADDFN(CTrueTalkNPC, CCharacter); + + ADDFN(CAutoMusicPlayer, CAutoMusicPlayerBase); + ADDFN(CAutoMusicPlayerBase, CGameObject); + ADDFN(CAutoSoundPlayer, CGameObject); + ADDFN(CAutoSoundPlayerADSR, CAutoSoundPlayer); + ADDFN(CBackgroundSoundMaker, CGameObject); + ADDFN(CBirdSong, CRoomAutoSoundPlayer); + ADDFN(CDomeFromTopOfWell, CViewAutoSoundPlayer); + ADDFN(CGondolierSong, CGameObject); + ADDFN(CEnterViewTogglesOtherMusic, CTriggerAutoMusicPlayer); + ADDFN(CGondolierSong, CRoomAutoSoundPlayer); + ADDFN(CMusicPlayer, CGameObject); + ADDFN(CNodeAutoSoundPlayer, CAutoSoundPlayer); + ADDFN(CRestrictedAutoMusicPlayer, CAutoMusicPlayer); + ADDFN(CRoomAutoSoundPlayer, CAutoSoundPlayer); + ADDFN(CRoomTriggerAutoMusicPlayer, CTriggerAutoMusicPlayer); + ADDFN(CSeasonNoises, CViewAutoSoundPlayer); + ADDFN(CSeasonalMusicPlayer, CAutoMusicPlayerBase); + ADDFN(CAutoMusicPlayer, CAutoMusicPlayerBase); + ADDFN(CAutoMusicPlayerBase, CAutoMusicPlayer); + ADDFN(CTitaniaSpeech, CGameObject); + ADDFN(CTriggerAutoMusicPlayer, CGameObject); + ADDFN(CViewAutoSoundPlayer, CAutoSoundPlayer); + ADDFN(CViewTogglesOtherMusic, CEnterViewTogglesOtherMusic); + ADDFN(CWaterLappingSounds, CRoomAutoSoundPlayer); + ADDFN(CStarControl, CGameObject); + ADDFN(CTimeEventInfo, ListItem); +} + +void CSaveableObject::freeClassList() { + Common::List<ClassDef *>::iterator i; + for (i = _classDefs->begin(); i != _classDefs->end(); ++i) + delete *i; + + delete _classDefs; + delete _classList; +} + +CSaveableObject *CSaveableObject::createInstance(const Common::String &name) { + return (*_classList)[name](); +} + +void CSaveableObject::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); +} + +void CSaveableObject::load(SimpleFile *file) { + file->readNumber(); +} + +void CSaveableObject::saveHeader(SimpleFile *file, int indent) { + file->writeClassStart(getType()->_className, indent); +} + +void CSaveableObject::saveFooter(SimpleFile *file, int indent) { + file->writeClassEnd(indent); +} + +bool CSaveableObject::isInstanceOf(const ClassDef *classDef) const { + for (ClassDef *def = getType(); def != nullptr; def = def->_parent) { + if (def == classDef) + return true; + } + + return false; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/saveable_object.h b/engines/titanic/core/saveable_object.h new file mode 100644 index 0000000000..6d80ad121d --- /dev/null +++ b/engines/titanic/core/saveable_object.h @@ -0,0 +1,110 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SAVEABLE_OBJECT_H +#define TITANIC_SAVEABLE_OBJECT_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/hash-str.h" +#include "common/list.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +class CSaveableObject; + +class ClassDef { +public: + const char *_className; + ClassDef *_parent; +public: + ClassDef(const char *className, ClassDef *parent) : + _className(className), _parent(parent) {} + virtual ~ClassDef() {} + virtual CSaveableObject *create(); +}; + +template<typename T> +class TypeTemplate : public ClassDef { +public: + TypeTemplate(const char *className, ClassDef *parent) : + ClassDef(className, parent) {} + virtual CSaveableObject *create() { return new T(); } +}; + +#define CLASSDEF \ + static ClassDef *_type; \ + virtual ClassDef *getType() const { return _type; } + +class CSaveableObject { + typedef CSaveableObject *(*CreateFunction)(); +private: + static Common::List<ClassDef *> *_classDefs; + static Common::HashMap<Common::String, CreateFunction> *_classList; +public: + /** + * Sets up the list of saveable object classes + */ + static void initClassList(); + + /** + * Free the list of saveable object classes + */ + static void freeClassList(); + + /** + * Creates a new instance of a saveable object class + */ + static CSaveableObject *createInstance(const Common::String &name); +public: + CLASSDEF + virtual ~CSaveableObject() {} + + bool isInstanceOf(const ClassDef *classDef) const; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Write out a header definition for the class to file + * prior to saving the actual data for the class + */ + virtual void saveHeader(SimpleFile *file, int indent); + + /** + * Writes out a footer for the class after it's data has + * been written to file + */ + virtual void saveFooter(SimpleFile *file, int indent); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SAVEABLE_OBJECT_H */ diff --git a/engines/titanic/core/static_image.cpp b/engines/titanic/core/static_image.cpp new file mode 100644 index 0000000000..977009e750 --- /dev/null +++ b/engines/titanic/core/static_image.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/static_image.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CStaticImage, CGameObject); + +void CStaticImage::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CStaticImage::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/static_image.h b/engines/titanic/core/static_image.h new file mode 100644 index 0000000000..7a715a84fa --- /dev/null +++ b/engines/titanic/core/static_image.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STATIC_IMAGE_H +#define TITANIC_STATIC_IMAGE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CStaticImage : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STATIC_IMAGE_H */ diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp new file mode 100644 index 0000000000..6adbbe39fa --- /dev/null +++ b/engines/titanic/core/tree_item.cpp @@ -0,0 +1,275 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/tree_item.h" +#include "titanic/core/dont_save_file_item.h" +#include "titanic/core/file_item.h" +#include "titanic/core/game_object.h" +#include "titanic/core/game_object_desc_item.h" +#include "titanic/core/link_item.h" +#include "titanic/core/mail_man.h" +#include "titanic/core/named_item.h" +#include "titanic/core/node_item.h" +#include "titanic/core/project_item.h" +#include "titanic/core/view_item.h" +#include "titanic/core/room_item.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/game_manager.h" +#include "titanic/game/placeholder/place_holder_item.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CTreeItem, CMessageTarget); + +CTreeItem::CTreeItem() : _parent(nullptr), _firstChild(nullptr), + _nextSibling(nullptr), _priorSibling(nullptr), _field14(0) { +} + +void CTreeItem::dump(int indent) { + CString line = dumpItem(indent); + debug("%s", line.c_str()); + + CTreeItem *item = getFirstChild(); + while (item) { + item->dump(indent + 1); + + item = item->getNextSibling(); + } +} + +CString CTreeItem::dumpItem(int indent) const { + CString result; + for (int idx = 0; idx < indent; ++idx) + result += '\t'; + result += getType()->_className; + + return result; +} + +void CTreeItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + CMessageTarget::save(file, indent); +} + +void CTreeItem::load(SimpleFile *file) { + file->readNumber(); + CMessageTarget::load(file); +} + +bool CTreeItem::isFileItem() const { + return isInstanceOf(CFileItem::_type); +} + +bool CTreeItem::isRoomItem() const { + return isInstanceOf(CRoomItem::_type); +} + +bool CTreeItem::isNodeItem() const { + return isInstanceOf(CNodeItem::_type); +} + +bool CTreeItem::isViewItem() const { + return isInstanceOf(CViewItem::_type); +} + +bool CTreeItem::isLinkItem() const { + return isInstanceOf(CLinkItem::_type); +} + +bool CTreeItem::isPlaceHolderItem() const { + return isInstanceOf(CPlaceHolderItem::_type); +} + +bool CTreeItem::isNamedItem() const { + return isInstanceOf(CNamedItem::_type); +} + +bool CTreeItem::isGameObject() const { + return isInstanceOf(CGameObject::_type); +} + +bool CTreeItem::isGameObjectDescItem() const { + return isInstanceOf(CGameObjectDescItem::_type); +} + +CGameManager *CTreeItem::getGameManager() const { + return _parent ? _parent->getGameManager() : nullptr; +} + +CProjectItem *CTreeItem::getRoot() const { + CTreeItem *parent = getParent(); + + if (parent) { + do { + parent = parent->getParent(); + } while (parent->getParent()); + } + + return dynamic_cast<CProjectItem *>(parent); +} + +CTreeItem *CTreeItem::getLastSibling() { + CTreeItem *item = this; + while (item->getNextSibling()) + item = item->getNextSibling(); + + return item; +} + +CTreeItem *CTreeItem::getLastChild() const { + if (!_firstChild) + return nullptr; + return _firstChild->getLastSibling(); +} + +CTreeItem *CTreeItem::scan(CTreeItem *item) const { + if (_firstChild) + return _firstChild; + + const CTreeItem *treeItem = this; + while (treeItem != item) { + if (treeItem->_nextSibling) + return treeItem->_nextSibling; + + treeItem = treeItem->_parent; + if (!treeItem) + break; + } + + return nullptr; +} + +CTreeItem *CTreeItem::findChildInstanceOf(ClassDef *classDef) const { + for (CTreeItem *treeItem = _firstChild; treeItem; treeItem = treeItem->getNextSibling()) { + if (treeItem->isInstanceOf(classDef)) + return treeItem; + } + + return nullptr; +} + +CTreeItem *CTreeItem::findNextInstanceOf(ClassDef *classDef, CTreeItem *startItem) const { + CTreeItem *treeItem = startItem ? startItem->getNextSibling() : getFirstChild(); + + for (; treeItem; treeItem = treeItem->getNextSibling()) { + if (treeItem->isInstanceOf(classDef)) + return treeItem; + } + + return nullptr; +} + +void CTreeItem::addUnder(CTreeItem *newParent) { + if (newParent->_firstChild) + addSibling(newParent->_firstChild->getLastSibling()); + else + setParent(newParent); +} + +void CTreeItem::setParent(CTreeItem *newParent) { + _parent = newParent; + _priorSibling = nullptr; + _nextSibling = newParent->_firstChild; + + if (newParent->_firstChild) + newParent->_firstChild->_priorSibling = this; + newParent->_firstChild = this; +} + +void CTreeItem::addSibling(CTreeItem *item) { + _priorSibling = item; + _nextSibling = item->_nextSibling; + _parent = item->_parent; + + if (item->_nextSibling) + item->_nextSibling->_priorSibling = this; + item->_nextSibling = this; +} + +void CTreeItem::moveUnder(CTreeItem *newParent) { + if (newParent) { + detach(); + addUnder(newParent); + } +} + +void CTreeItem::destroyAll() { + destroyChildren(); + detach(); + delete this; +} + +int CTreeItem::destroyChildren() { + if (!_firstChild) + return 0; + + CTreeItem *item = _firstChild, *child, *nextSibling; + int total = 0; + + do { + child = item->_firstChild; + nextSibling = item->_nextSibling; + + if (child) + total += item->destroyChildren(); + item->detach(); + delete item; + ++total; + } while ((item = nextSibling) != nullptr); + + return total; +} + +void CTreeItem::detach() { + // Delink this item from any prior and/or next siblings + if (_priorSibling) + _priorSibling->_nextSibling = _nextSibling; + if (_nextSibling) + _nextSibling->_priorSibling = _priorSibling; + + if (_parent && _parent->_firstChild == this) + _parent->_firstChild = _nextSibling; + + _priorSibling = _nextSibling = _parent = nullptr; +} + +CNamedItem *CTreeItem::findByName(const CString &name, int maxLen) { + CString nameLower = name; + nameLower.toLowercase(); + + for (CTreeItem *treeItem = this; treeItem; treeItem = treeItem->scan(this)) { + CString nodeName = treeItem->getName(); + nodeName.toLowercase(); + + if (maxLen) { + if (nodeName.left(maxLen).compareTo(nameLower)) + return dynamic_cast<CNamedItem *>(treeItem); + } else { + if (!nodeName.compareTo(nameLower)) + return dynamic_cast<CNamedItem *>(treeItem); + } + } + + return nullptr; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h new file mode 100644 index 0000000000..db4ba30a44 --- /dev/null +++ b/engines/titanic/core/tree_item.h @@ -0,0 +1,252 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TREE_ITEM_H +#define TITANIC_TREE_ITEM_H + +#include "titanic/core/message_target.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +class CGameManager; +class CMovieClipList; +class CNamedItem; +class CProjectItem; +class CScreenManager; +class CViewItem; + +class CTreeItem: public CMessageTarget { + friend class CMessage; + DECLARE_MESSAGE_MAP; +private: + CTreeItem *_parent; + CTreeItem *_nextSibling; + CTreeItem *_priorSibling; + CTreeItem *_firstChild; + int _field14; +public: + CLASSDEF; + CTreeItem(); + + + /** + * Dump the item and any of it's children + */ + void dump(int indent); + + /** + * Dump the item + */ + virtual CString dumpItem(int indent) const; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Get the game manager for the project + */ + virtual CGameManager *getGameManager() const; + + /** + * Returns true if the item is a file item + */ + virtual bool isFileItem() const; + + /** + * Returns true if the item is a room item + */ + virtual bool isRoomItem() const; + + /** + * Returns true if the item is a node item + */ + virtual bool isNodeItem() const; + + /** + * Returns true if the item is a view item + */ + virtual bool isViewItem() const; + + /** + * Returns true if the item is a link item + */ + virtual bool isLinkItem() const; + + /** + * Returns true if the item is a placeholder item + */ + virtual bool isPlaceHolderItem() const; + + /** + * Returns true if the item is a named item + */ + virtual bool isNamedItem() const; + + /** + * Returns true if the item is a game object + */ + virtual bool isGameObject() const; + + /** + * Returns true if the item is a game object desc item + */ + virtual bool isGameObjectDescItem() const; + + /** + * Gets the name of the item, if any + */ + virtual const CString getName() const { return CString(); } + + /** + * Compares the name of the item to a passed name + */ + virtual int compareTo(const CString &name, int maxLen = 0) const { return false; } + + /** + * Returns the clip list, if any, associated with the item + */ + virtual const CMovieClipList *getMovieClips() const { return nullptr; } + + /** + * Returns true if the given item connects to another specified view + */ + virtual bool connectsTo(CViewItem *destView) const { return false; } + + /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager) {} + + /** + * Gets the bounds occupied by the item + */ + virtual Rect getBounds() const { return Rect(); } + + /** + * Called when the view changes + */ + virtual void viewChange() {} + + /** + * Get the parent for the given item + */ + CTreeItem *getParent() const { return _parent; } + + /** + * Jumps up through the parents to find the root item + */ + CProjectItem *getRoot() const; + + /** + * Get the next sibling + */ + CTreeItem *getNextSibling() const { return _nextSibling; } + + /** + * Get the prior sibling + */ + CTreeItem *getPriorSibling() const { return _priorSibling; } + + /** + * Get the last sibling of this sibling + */ + CTreeItem *getLastSibling(); + + /** + * Get the first child of the item, if any + */ + CTreeItem *getFirstChild() const { return _firstChild; } + + /** + * Get the last child of the item, if any + */ + CTreeItem *getLastChild() const; + + /** + * Given all the recursive children of the tree item, gives the next + * item in sequence to the passed starting item + */ + CTreeItem *scan(CTreeItem *item) const; + + /** + * Find the first child item that is of a given type + */ + CTreeItem *findChildInstanceOf(ClassDef *classDef) const; + + /** + * Find the next sibling item that is of the given type + */ + CTreeItem *findNextInstanceOf(ClassDef *classDef, CTreeItem *startItem) const; + + /** + * Adds the item under another tree item + */ + void addUnder(CTreeItem *newParent); + + /** + * Sets the parent for the item + */ + void setParent(CTreeItem *newParent); + + /** + * Adds the item as a sibling of another item + */ + void addSibling(CTreeItem *item); + + /** + * Moves the tree item to be under another parent + */ + void moveUnder(CTreeItem *newParent); + + /** + * Destroys both the item as well as any of it's children + */ + void destroyAll(); + + /** + * Destroys all child tree items under this one. + * @returns Total number of tree items recursively removed + */ + int destroyChildren(); + + /** + * Detach the tree item from any other associated tree items + */ + void detach(); + + /** + * Finds a tree item by name + */ + CNamedItem *findByName(const CString &name, int maxLen = 0); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TREE_ITEM_H */ diff --git a/engines/titanic/core/turn_on_object.cpp b/engines/titanic/core/turn_on_object.cpp new file mode 100644 index 0000000000..221602bb7b --- /dev/null +++ b/engines/titanic/core/turn_on_object.cpp @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/turn_on_object.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CTurnOnObject, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + +CTurnOnObject::CTurnOnObject() : CBackground(), _msgName("NULL") { +} + +void CTurnOnObject::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_msgName, indent); + + CBackground::save(file, indent); +} + +void CTurnOnObject::load(SimpleFile *file) { + file->readNumber(); + _msgName = file->readString(); + + CBackground::load(file); +} + +bool CTurnOnObject::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CTurnOnObject::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + CTurnOn turnOn; + turnOn.execute(_msgName); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/turn_on_object.h b/engines/titanic/core/turn_on_object.h new file mode 100644 index 0000000000..0f7cd76382 --- /dev/null +++ b/engines/titanic/core/turn_on_object.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TURN_ON_OBJECT_H +#define TITANIC_TURN_ON_OBJECT_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CTurnOnObject : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); +protected: + CString _msgName; +public: + CLASSDEF; + CTurnOnObject(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TURN_ON_OBJECT_H */ diff --git a/engines/titanic/core/turn_on_play_sound.cpp b/engines/titanic/core/turn_on_play_sound.cpp new file mode 100644 index 0000000000..2f9dba24a6 --- /dev/null +++ b/engines/titanic/core/turn_on_play_sound.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/turn_on_play_sound.h" + +namespace Titanic { + +CTurnOnPlaySound::CTurnOnPlaySound() : CTurnOnObject(), + _string3("NULL"), _fieldF8(80), _fieldFC(0) { +} + +void CTurnOnPlaySound::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + + CTurnOnObject::save(file, indent); +} + +void CTurnOnPlaySound::load(SimpleFile *file) { + file->readNumber(); + _string3 = file->readString(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + + CTurnOnObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/turn_on_play_sound.h b/engines/titanic/core/turn_on_play_sound.h new file mode 100644 index 0000000000..1164135071 --- /dev/null +++ b/engines/titanic/core/turn_on_play_sound.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TURN_ON_PLAY_SOUND_H +#define TITANIC_TURN_ON_PLAY_SOUND_H + +#include "titanic/core/turn_on_object.h" + +namespace Titanic { + +class CTurnOnPlaySound : public CTurnOnObject { +private: + CString _string3; + int _fieldF8; + int _fieldFC; +public: + CLASSDEF; + CTurnOnPlaySound(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TURN_ON_PLAY_SOUND_H */ diff --git a/engines/titanic/core/turn_on_turn_off.cpp b/engines/titanic/core/turn_on_turn_off.cpp new file mode 100644 index 0000000000..d43ddf7038 --- /dev/null +++ b/engines/titanic/core/turn_on_turn_off.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/turn_on_turn_off.h" + +namespace Titanic { + +CTurnOnTurnOff::CTurnOnTurnOff() : CBackground(), _fieldE0(0), + _fieldE4(0), _fieldE8(0), _fieldEC(0), _fieldF0(0) { +} + +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(_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(); + _fieldF0 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/turn_on_turn_off.h b/engines/titanic/core/turn_on_turn_off.h new file mode 100644 index 0000000000..adca6876ff --- /dev/null +++ b/engines/titanic/core/turn_on_turn_off.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TURN_ON_TURN_OFF_H +#define TITANIC_TURN_ON_TURN_OFF_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CTurnOnTurnOff : public CBackground { +private: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; +public: + CLASSDEF; + CTurnOnTurnOff(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TURN_ON_TURN_OFF_H */ diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp new file mode 100644 index 0000000000..03e2753839 --- /dev/null +++ b/engines/titanic/core/view_item.cpp @@ -0,0 +1,332 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game_manager.h" +#include "titanic/support/screen_manager.h" +#include "titanic/core/project_item.h" +#include "titanic/core/room_item.h" +#include "titanic/core/view_item.h" +#include "titanic/messages/messages.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CViewItem, CNamedItem) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MouseDoubleClickMsg) + ON_MESSAGE(MouseMoveMsg) +END_MESSAGE_MAP() + +CViewItem::CViewItem() : CNamedItem() { + Common::fill(&_buttonUpTargets[0], &_buttonUpTargets[4], (CTreeItem *)nullptr); + _field24 = 0; + _angle = 0.0; + _viewNumber = 0; + setAngle(0.0); +} + +void CViewItem::setAngle(double angle) { + _angle = angle; + _viewPos.x = (int16)(cos(_angle) * 30.0); + _viewPos.y = (int16)(sin(_angle) * -30.0); +} + +void CViewItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + _resourceKey.save(file, indent); + file->writeQuotedLine("V", indent); + file->writeFloatLine(_angle, indent + 1); + file->writeNumberLine(_viewNumber, indent + 1); + + CNamedItem::save(file, indent); +} + +void CViewItem::load(SimpleFile *file) { + int val = file->readNumber(); + + switch (val) { + case 1: + _resourceKey.load(file); + // Deliberate fall-through + + default: + file->readBuffer(); + setAngle(file->readFloat()); + _viewNumber = file->readNumber(); + break; + } + + CNamedItem::load(file); +} + +bool CViewItem::getResourceKey(CResourceKey *key) { + *key = _resourceKey; + CString filename = key->exists(); + return !filename.empty(); +} + +void CViewItem::leaveView(CViewItem *newView) { + // Only do the processing if we've been passed a view, and it's not the same + if (newView && newView != this) { + CLeaveViewMsg viewMsg(this, newView); + viewMsg.execute(this, nullptr, MSGFLAG_SCAN); + + CNodeItem *oldNode = findNode(); + CNodeItem *newNode = newView->findNode(); + if (newNode != oldNode) { + CLeaveNodeMsg nodeMsg(oldNode, newNode); + nodeMsg.execute(oldNode, nullptr, MSGFLAG_SCAN); + + CRoomItem *oldRoom = oldNode->findRoom(); + CRoomItem *newRoom = newNode->findRoom(); + if (newRoom != oldRoom) { + CGameManager *gm = getGameManager(); + if (gm) + gm->viewChange(); + + CLeaveRoomMsg roomMsg(oldRoom, newRoom); + roomMsg.execute(oldRoom, nullptr, MSGFLAG_SCAN); + } + } + } +} + +void CViewItem::preEnterView(CViewItem *newView) { + // Only do the processing if we've been passed a view, and it's not the same + if (newView && newView != this) { + CPreEnterViewMsg viewMsg(this, newView); + viewMsg.execute(this, nullptr, MSGFLAG_SCAN); + + CNodeItem *oldNode = findNode(); + CNodeItem *newNode = newView->findNode(); + if (newNode != oldNode) { + CPreEnterNodeMsg nodeMsg(oldNode, newNode); + nodeMsg.execute(oldNode, nullptr, MSGFLAG_SCAN); + + CRoomItem *oldRoom = oldNode->findRoom(); + CRoomItem *newRoom = newNode->findRoom(); + if (newRoom != oldRoom) { + CPreEnterRoomMsg roomMsg(oldRoom, newRoom); + roomMsg.execute(oldRoom, nullptr, MSGFLAG_SCAN); + } + } + } +} + +void CViewItem::enterView(CViewItem *newView) { + // Only do the processing if we've been passed a view, and it's not the same + if (newView && newView != this) { + CEnterViewMsg viewMsg(this, newView); + viewMsg.execute(this, nullptr, MSGFLAG_SCAN); + + CNodeItem *oldNode = findNode(); + CNodeItem *newNode = newView->findNode(); + if (newNode != oldNode) { + CEnterNodeMsg nodeMsg(oldNode, newNode); + nodeMsg.execute(oldNode, nullptr, MSGFLAG_SCAN); + + CRoomItem *oldRoom = oldNode->findRoom(); + CRoomItem *newRoom = newNode->findRoom(); + + CPetControl *petControl = nullptr; + if (newRoom != nullptr) { + petControl = newRoom->getRoot()->getPetControl(); + if (petControl) + petControl->enterNode(newNode); + } + + if (newRoom != oldRoom) { + CEnterRoomMsg roomMsg(oldRoom, newRoom); + roomMsg.execute(oldRoom, nullptr, MSGFLAG_SCAN); + + if (petControl) + petControl->enterRoom(newRoom); + } + } + } +} + +CLinkItem *CViewItem::findLink(CViewItem *newView) { + for (CTreeItem *treeItem = getFirstChild(); treeItem; + treeItem = scan(treeItem)) { + CLinkItem *link = static_cast<CLinkItem *>(treeItem); + if (link && link->connectsTo(newView)) + return link; + } + + return nullptr; +} + +bool CViewItem::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (msg->_buttons & MB_LEFT) { + if (!handleMouseMsg(msg, true)) { + CGameManager *gm = getGameManager(); + if (gm->test54()) { + findNode()->findRoom(); + + CLinkItem *linkItem = dynamic_cast<CLinkItem *>( + findChildInstanceOf(CLinkItem::_type)); + while (linkItem) { + if (linkItem->_bounds.contains(msg->_mousePos)) { + gm->_gameState.triggerLink(linkItem); + return true; + } + + linkItem = dynamic_cast<CLinkItem *>( + findNextInstanceOf(CLinkItem::_type, linkItem)); + } + } + } + } + + return true; +} + +bool CViewItem::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (msg->_buttons & MB_LEFT) + handleMouseMsg(msg, false); + + return true; +} + +bool CViewItem::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + if (msg->_buttons & MB_LEFT) + handleMouseMsg(msg, false); + + return true; +} + +bool CViewItem::MouseMoveMsg(CMouseMoveMsg *msg) { + CScreenManager *screenManager = CScreenManager::_screenManagerPtr; + uint changeCount = screenManager->_mouseCursor->getChangeCount(); + + if (handleMouseMsg(msg, true)) { + // If the cursor hasn't been set in the call to handleMouseMsg, + // then reset it back to the default arrow cursor + if (screenManager->_mouseCursor->getChangeCount() == changeCount) + screenManager->_mouseCursor->setCursor(CURSOR_ARROW); + } else { + // Iterate through each link item, and if any is highlighted, + // change the mouse cursor to the designated cursor for the item + CTreeItem *treeItem = getFirstChild(); + while (treeItem) { + CLinkItem *linkItem = dynamic_cast<CLinkItem *>(treeItem); + if (linkItem && linkItem->_bounds.contains(msg->_mousePos)) { + screenManager->_mouseCursor->setCursor(linkItem->_cursorId); + return true; + } + + treeItem = treeItem->getNextSibling(); + } + + if (!handleMouseMsg(msg, false) || (screenManager->_mouseCursor->getChangeCount() == changeCount)) + screenManager->_mouseCursor->setCursor(CURSOR_ARROW); + } + + return true; +} + +bool CViewItem::handleMouseMsg(CMouseMsg *msg, bool flag) { + CMouseButtonUpMsg *upMsg = dynamic_cast<CMouseButtonUpMsg *>(msg); + if (upMsg) { + handleButtonUpMsg(upMsg); + return true; + } + + Common::Array<CGameObject *> gameObjects; + for (CTreeItem *treeItem = scan(this); treeItem; treeItem = treeItem->scan(this)) { + CGameObject *gameObject = dynamic_cast<CGameObject *>(treeItem); + if (gameObject) { + if (gameObject->checkPoint(msg->_mousePos, false, true) && + (!flag || !gameObject->_field60)) { + if (gameObjects.size() < 256) + gameObjects.push_back(gameObject); + } + } + } + + const CMouseMoveMsg *moveMsg = dynamic_cast<const CMouseMoveMsg *>(msg); + if (moveMsg) { + if (gameObjects.size() == 0) + return false; + + for (int idx = (int)gameObjects.size() - 1; idx >= 0; ++idx) { + if (gameObjects[idx]->_cursorId != CURSOR_IGNORE) { + CScreenManager::_screenManagerPtr->_mouseCursor->setCursor(gameObjects[idx]->_cursorId); + break; + } + } + } + if (gameObjects.size() == 0) + return false; + + bool result = false; + for (int idx = (int)gameObjects.size() - 1; idx >= 0; --idx) { + if (msg->execute(gameObjects[idx])) { + if (msg->isButtonDownMsg()) + _buttonUpTargets[msg->_buttons >> 1] = gameObjects[idx]; + return true; + } + + if (CMouseMsg::isSupportedBy(gameObjects[idx])) + result = true; + } + + return result; +} + +void CViewItem::handleButtonUpMsg(CMouseButtonUpMsg *msg) { + CTreeItem *&target = _buttonUpTargets[msg->_buttons >> 1]; + + if (target) { + msg->execute(target); + target = nullptr; + } +} + +void CViewItem::getPosition(double &xp, double &yp, double &zp) { + // Get the position of the owning node within the room + CNodeItem *node = findNode(); + node->getPosition(xp, yp, zp); + + // Adjust the position slightly to compensate for view's angle, + // ensuring different direction views don't all have the same position + xp += cos(_angle) * 0.5; + yp -= sin(_angle) * 0.5; +} + +CString CViewItem::getFullViewName() const { + CNodeItem *node = findNode(); + CRoomItem *room = node->findRoom(); + + return CString::format("%s.%s.%s", room->getName().c_str(), + node->getName().c_str(), getName().c_str()); +} + +CString CViewItem::getNodeViewName() const { + CNodeItem *node = findNode(); + + return CString::format("%s.%s", node->getName().c_str(), getName().c_str()); +} + +} // End of namespace Titanic diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h new file mode 100644 index 0000000000..ceb8a020da --- /dev/null +++ b/engines/titanic/core/view_item.h @@ -0,0 +1,122 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_VIEW_ITEM_H +#define TITANIC_VIEW_ITEM_H + +#include "titanic/core/link_item.h" +#include "titanic/core/named_item.h" +#include "titanic/core/resource_key.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CViewItem : public CNamedItem { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MouseMoveMsg(CMouseMoveMsg *msg); + bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); +private: + CTreeItem *_buttonUpTargets[4]; +private: + /** + * Sets the angle of the view relative to the node it belongs to + */ + void setAngle(double angle); + + /** + * Called to handle mouse messagaes on the view + */ + bool handleMouseMsg(CMouseMsg *msg, bool flag); + + /** + * Handles mouse button up messages + */ + void handleButtonUpMsg(CMouseButtonUpMsg *msg); +protected: + int _field24; + CResourceKey _resourceKey; + Point _viewPos; +public: + int _viewNumber; + double _angle; +public: + CLASSDEF; + CViewItem(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Get the resource key for the view + */ + bool getResourceKey(CResourceKey *key); + + /** + * Called when leaving the view + */ + void leaveView(CViewItem *newView); + + /** + * Called on an old view just left, and about to enter a new view + */ + void preEnterView(CViewItem *newView); + + /** + * Called when a new view is being entered + */ + void enterView(CViewItem *newView); + + /** + * Finds a link which connects to another designated view + */ + CLinkItem *findLink(CViewItem *newView); + + /** + * Return the full Id of the current view in a + * room.node.view tuplet form + */ + CString getFullViewName() const; + + /** + * Return the Id of the current view in a + * room.node.view tuplet form + */ + CString getNodeViewName() const; + + /** + * Gets the relative position of the view within the owning room + */ + void getPosition(double &xp, double &yp, double &zp); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NAMED_ITEM_H */ diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp new file mode 100644 index 0000000000..37fc546851 --- /dev/null +++ b/engines/titanic/debugger.cpp @@ -0,0 +1,263 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/debugger.h" +#include "titanic/titanic.h" +#include "titanic/core/tree_item.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +Debugger::Debugger(TitanicEngine *vm) : GUI::Debugger(), _vm(vm) { + registerCmd("continue", WRAP_METHOD(Debugger, cmdExit)); + registerCmd("dump", WRAP_METHOD(Debugger, cmdDump)); + registerCmd("room", WRAP_METHOD(Debugger, cmdRoom)); + registerCmd("pet", WRAP_METHOD(Debugger, cmdPET)); + registerCmd("item", WRAP_METHOD(Debugger, cmdItem)); +} + +int Debugger::strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + +CRoomItem *Debugger::findRoom(const char *name) { + CTreeItem *root = g_vm->_window->_gameManager->_project; + CRoomItem *roomItem = dynamic_cast<CRoomItem *>(root->findByName(name)); + if (roomItem) + return roomItem; + + int roomNumber = strToInt(name); + for (CTreeItem *treeItem = root; treeItem; treeItem = treeItem->scan(root)) { + roomItem = dynamic_cast<CRoomItem *>(treeItem); + if (roomItem && roomItem->_roomNumber == roomNumber) + return roomItem; + } + + return nullptr; +} + +CNodeItem *Debugger::findNode(CRoomItem *room, const char *name) { + CNodeItem *nodeItem = dynamic_cast<CNodeItem *>(room->findByName(name)); + if (nodeItem) + return nodeItem; + + int nodeNumber = strToInt(name); + nodeItem = dynamic_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); + while (nodeItem) { + if (nodeItem->_nodeNumber == nodeNumber) + return nodeItem; + + nodeItem = dynamic_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, nodeItem)); + } + + return nullptr; +} + +CViewItem *Debugger::findView(CNodeItem *node, const char *name) { + CViewItem *viewItem = dynamic_cast<CViewItem *>(node->findByName(name)); + if (viewItem) + return viewItem; + + int viewNumber = strToInt(name); + viewItem = dynamic_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); + while (viewItem) { + if (viewItem->_viewNumber == viewNumber) + return viewItem; + + viewItem = dynamic_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, viewItem)); + } + + return nullptr; +} + +void Debugger::listRooms() { + CGameManager &gm = *g_vm->_window->_gameManager; + CTreeItem *root = gm._project; + CViewItem *view = gm._gameState._gameLocation.getView(); + CNodeItem *node = gm._gameState._gameLocation.getNode(); + CRoomItem *room = gm._gameState._gameLocation.getRoom(); + debugPrintf("Current location: %s, %s, %s\n", room->getName().c_str(), + node->getName().c_str(), view->getName().c_str()); + + debugPrintf("Available rooms:\n"); + for (CTreeItem *treeItem = root; treeItem; treeItem = treeItem->scan(root)) { + CRoomItem *roomItem = dynamic_cast<CRoomItem *>(treeItem); + if (roomItem) + debugPrintf("%d - %s\n", roomItem->_roomNumber, roomItem->_name.c_str()); + } +} + +void Debugger::listRoom(CRoomItem *room) { + for (CTreeItem *treeItem = room; treeItem; treeItem = treeItem->scan(room)) { + CNodeItem *nodeItem = dynamic_cast<CNodeItem *>(treeItem); + if (nodeItem) + debugPrintf("%s\n", nodeItem->_name.c_str()); + } +} + +void Debugger::listNode(CNodeItem *node) { + for (CTreeItem *treeItem = node; treeItem; treeItem = treeItem->scan(node)) { + CViewItem *viewItem = dynamic_cast<CViewItem *>(treeItem); + if (viewItem) + debugPrintf("%s\n", viewItem->_name.c_str()); + } +} + +bool Debugger::cmdDump(int argc, const char **argv) { + // Get the starting node + CTreeItem *root = g_vm->_window->_gameManager->_project; + if (argc == 2) + root = root->findByName(argv[1]); + + if (root == nullptr) { + debugPrintf("Could not find item\n"); + } else { + root->dump(0); + debugPrintf("Item and it's content were dumped to stdout\n"); + } + + return true; +} + +bool Debugger::cmdRoom(int argc, const char **argv) { + if (argc == 1) { + listRooms(); + } else if (argc >= 2) { + CRoomItem *roomItem = findRoom(argv[1]); + + if (!roomItem) + debugPrintf("Could not find room - %s\n", argv[1]); + else if (argc == 2) + listRoom(roomItem); + else { + CNodeItem *nodeItem = findNode(roomItem, argv[2]); + + if (!nodeItem) + debugPrintf("Could not find node - %s\n", argv[2]); + else if (argc == 3) + listNode(nodeItem); + else { + CViewItem *viewItem = findView(nodeItem, argv[3]); + + if (!viewItem) { + debugPrintf("Could not find view - %s\n", argv[3]); + } else { + // Change to the specified view + g_vm->_window->_gameManager->_gameState.changeView(viewItem, nullptr); + return false; + } + } + } + } + + return true; +} + +bool Debugger::cmdPET(int argc, const char **argv) { + CGameManager &gameManager = *g_vm->_window->_gameManager; + CGameState &gameState = gameManager._gameState; + + if (argc == 2) { + CString s(argv[1]); + s.toLowercase(); + + if (s == "on") { + gameState._petActive = true; + gameManager.initBounds(); + debugPrintf("PET is now on\n"); + return true; + } else if (s == "off") { + gameState._petActive = false; + gameManager.update(); + debugPrintf("PET is now off\n"); + return true; + } + } + + debugPrintf("%s [on | off]\n", argv[0]); + return true; +} + +bool Debugger::cmdItem(int argc, const char **argv) { + CGameManager &gameManager = *g_vm->_window->_gameManager; + CGameState &gameState = gameManager._gameState; + + if (argc == 1) { + // No parameters, so list the available items + debugPrintf("item [<name> [ add ]]\n"); + for (int idx = 0; idx < 40; ++idx) + debugPrintf("%s\n", g_vm->_itemIds[idx].c_str()); + } else { + // Ensure the specified name is a valid inventory item + int itemIndex; + for (itemIndex = 0; itemIndex < 40; ++itemIndex) { + if (g_vm->_itemIds[itemIndex] == argv[1]) + break; + } + if (itemIndex == 40) { + debugPrintf("Could not find item with that name\n"); + return true; + } + + // Get the item + CCarry *item = static_cast<CCarry *>( + g_vm->_window->_project->findByName(argv[1])); + assert(item); + + if (argc == 2) { + // List it's details + CTreeItem *treeItem = item; + CString fullName; + while ((treeItem = treeItem->getParent()) != nullptr) { + if (!treeItem->getName().empty()) + fullName = treeItem->getName() + "." + fullName; + } + + debugPrintf("Current location: %s\n", fullName.c_str()); + } else if (CString(argv[2]) == "add") { + // Ensure the PET is active and add the item to the inventory + gameState._petActive = true; + gameManager.initBounds(); + item->petAddToInventory(); + + return false; + } else { + debugPrintf("Unknown command\n"); + } + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/debugger.h b/engines/titanic/debugger.h new file mode 100644 index 0000000000..5edb7cb324 --- /dev/null +++ b/engines/titanic/debugger.h @@ -0,0 +1,101 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DEBUGGER_H +#define TITANIC_DEBUGGER_H + +#include "common/scummsys.h" +#include "gui/debugger.h" +#include "titanic/core/room_item.h" +#include "titanic/core/node_item.h" +#include "titanic/core/view_item.h" + +namespace Titanic { + +class TitanicEngine; + +class Debugger : public GUI::Debugger { +private: + /** + * Converts a decimal or hexadecimal string into a number + */ + int strToInt(const char *s); + + /** + * Find a room by name or number + */ + CRoomItem *findRoom(const char *name); + + /** + * Find a node within a room by name or number + */ + CNodeItem *findNode(CRoomItem *room, const char *name); + + /** + * Find a view within a room node by name or number + */ + CViewItem *findView(CNodeItem *node, const char *name); + + /** + * List all the rooms in the game + */ + void listRooms(); + + /** + * List the nodes within a room + */ + void listRoom(CRoomItem *room); + + /** + * List the views within a room node + */ + void listNode(CNodeItem *node); + + /** + * Dump a portion of the game project + */ + bool cmdDump(int argc, const char **argv); + + /** + * List room details, or jump to a specific view + */ + bool cmdRoom(int argc, const char **argv); + + /** + * Turn the PET on or off + */ + bool cmdPET(int argc, const char **argv); + + /** + * Item handling + */ + bool cmdItem(int argc, const char **argv); +protected: + TitanicEngine *_vm; +public: + Debugger(TitanicEngine *vm); + virtual ~Debugger() {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DEBUGGER_H */ diff --git a/engines/titanic/detection.cpp b/engines/titanic/detection.cpp new file mode 100644 index 0000000000..86d26f2f27 --- /dev/null +++ b/engines/titanic/detection.cpp @@ -0,0 +1,189 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/titanic.h" +#include "titanic/core/project_item.h" +#include "titanic/support/simple_file.h" + +#include "base/plugins.h" +#include "common/savefile.h" +#include "common/str-array.h" +#include "common/memstream.h" +#include "engines/advancedDetector.h" +#include "common/system.h" +#include "graphics/colormasks.h" +#include "graphics/surface.h" + +#define MAX_SAVES 99 + +namespace Titanic { + +struct TitanicGameDescription { + ADGameDescription desc; +}; + +uint32 TitanicEngine::getFeatures() const { + return _gameDescription->desc.flags; +} + +bool TitanicEngine::isDemo() const { + return (bool)(_gameDescription->desc.flags & ADGF_DEMO); +} + +Common::Language TitanicEngine::getLanguage() const { + return _gameDescription->desc.language; +} + +} // End of namespace Titanic + +static const PlainGameDescriptor TitanicGames[] = { + {"titanic", "Starship Titanic"}, + {0, 0} +}; + +#include "titanic/detection_tables.h" + +class TitanicMetaEngine : public AdvancedMetaEngine { +public: + TitanicMetaEngine() : AdvancedMetaEngine(Titanic::gameDescriptions, sizeof(Titanic::TitanicGameDescription), TitanicGames) { + _maxScanDepth = 3; + } + + virtual const char *getName() const { + return "Titanic Engine"; + } + + virtual const char *getOriginalCopyright() const { + return "Titanic Engine (c)"; + } + + virtual bool hasFeature(MetaEngineFeature f) const; + virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const; + virtual SaveStateList listSaves(const char *target) const; + virtual int getMaximumSaveSlot() const; + virtual void removeSaveState(const char *target, int slot) const; + SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; +}; + +bool TitanicMetaEngine::hasFeature(MetaEngineFeature f) const { + return + (f == kSupportsListSaves) || + (f == kSupportsLoadingDuringStartup) || + (f == kSupportsDeleteSave) || + (f == kSavesSupportMetaInfo) || + (f == kSavesSupportThumbnail); +} + +bool Titanic::TitanicEngine::hasFeature(EngineFeature f) const { + return + (f == kSupportsRTL) || + (f == kSupportsLoadingDuringRuntime) || + (f == kSupportsSavingDuringRuntime); +} + +bool TitanicMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { + const Titanic::TitanicGameDescription *gd = (const Titanic::TitanicGameDescription *)desc; + *engine = new Titanic::TitanicEngine(syst, gd); + + return gd != 0; +} + +SaveStateList TitanicMetaEngine::listSaves(const char *target) const { + Common::SaveFileManager *saveFileMan = g_system->getSavefileManager(); + Common::StringArray filenames; + Common::String saveDesc; + Common::String pattern = Common::String::format("%s.0##", target); + Titanic::TitanicSavegameHeader header; + + filenames = saveFileMan->listSavefiles(pattern); + + SaveStateList saveList; + for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) { + const char *ext = strrchr(file->c_str(), '.'); + int slot = ext ? atoi(ext + 1) : -1; + + if (slot >= 0 && slot < MAX_SAVES) { + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file); + + if (in) { + Titanic::CompressedFile cf; + cf.open(in); + + if (Titanic::CProjectItem::readSavegameHeader(&cf, header)) + saveList.push_back(SaveStateDescriptor(slot, header._saveName)); + + if (header._thumbnail) { + header._thumbnail->free(); + delete header._thumbnail; + } + + cf.close(); + } + } + } + + // Sort saves based on slot number. + Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator()); + return saveList; +} + +int TitanicMetaEngine::getMaximumSaveSlot() const { + return MAX_SAVES; +} + +void TitanicMetaEngine::removeSaveState(const char *target, int slot) const { + Common::String filename = Common::String::format("%s.%03d", target, slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +SaveStateDescriptor TitanicMetaEngine::querySaveMetaInfos(const char *target, int slot) const { + Common::String filename = Common::String::format("%s.%03d", target, slot); + Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename); + + if (f) { + Titanic::CompressedFile file; + file.open(f); + + Titanic::TitanicSavegameHeader header; + Titanic::CProjectItem::readSavegameHeader(&file, header); + + file.close(); + + // Create the return descriptor + SaveStateDescriptor desc(slot, header._saveName); + desc.setThumbnail(header._thumbnail); + desc.setSaveDate(header._year, header._month, header._day); + desc.setSaveTime(header._hour, header._minute); + desc.setPlayTime(header._totalFrames * GAME_FRAME_TIME); + + return desc; + } + + return SaveStateDescriptor(); +} + + +#if PLUGIN_ENABLED_DYNAMIC(TITANIC) + REGISTER_PLUGIN_DYNAMIC(TITANIC, PLUGIN_TYPE_ENGINE, TitanicMetaEngine); +#else + REGISTER_PLUGIN_STATIC(TITANIC, PLUGIN_TYPE_ENGINE, TitanicMetaEngine); +#endif diff --git a/engines/titanic/detection_tables.h b/engines/titanic/detection_tables.h new file mode 100644 index 0000000000..d4acebc3bf --- /dev/null +++ b/engines/titanic/detection_tables.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +namespace Titanic { + +static const TitanicGameDescription gameDescriptions[] = { + { + { + "titanic", + 0, + AD_ENTRY1s("newgame.st", "c276f2661f0d0a547445a65db78b2292", 87227), + Common::EN_ANY, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, + +#if 0 + // German version currently disabled because it won't start up, + // even with the English generated titanic.dat file + { + { + "titanic", + 0, + AD_ENTRY1s("newgame.st", "db22924adfd6730f4b79f4e51b25e779", 87608), + Common::DE_DEU, + Common::kPlatformWindows, + ADGF_NO_FLAGS, + GUIO1(GUIO_NONE) + }, + }, +#endif + + { AD_TABLE_END_MARKER } +}; + +} // End of namespace Titanic diff --git a/engines/titanic/events.cpp b/engines/titanic/events.cpp new file mode 100644 index 0000000000..318ddf5726 --- /dev/null +++ b/engines/titanic/events.cpp @@ -0,0 +1,150 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "common/events.h" +#include "common/system.h" +#include "engines/util.h" +#include "titanic/events.h" +#include "titanic/titanic.h" +#include "titanic/main_game_window.h" + +namespace Titanic { + +Events::Events(TitanicEngine *vm): _vm(vm), _frameCounter(1), + _priorFrameTime(0) { +} + +void Events::pollEvents() { + checkForNextFrameCounter(); + + Common::Event event; + if (!g_system->getEventManager()->pollEvent(event)) + return; + + switch (event.type) { + case Common::EVENT_MOUSEMOVE: + _mousePos = event.mouse; + eventTarget()->mouseMove(_mousePos); + break; + case Common::EVENT_LBUTTONDOWN: + _mousePos = event.mouse; + eventTarget()->leftButtonDown(_mousePos); + break; + case Common::EVENT_LBUTTONUP: + _mousePos = event.mouse; + eventTarget()->leftButtonUp(_mousePos); + break; + case Common::EVENT_MBUTTONDOWN: + _mousePos = event.mouse; + eventTarget()->middleButtonDown(_mousePos); + break; + case Common::EVENT_MBUTTONUP: + _mousePos = event.mouse; + eventTarget()->middleButtonUp(_mousePos); + break; + case Common::EVENT_RBUTTONDOWN: + _mousePos = event.mouse; + eventTarget()->rightButtonDown(_mousePos); + break; + case Common::EVENT_RBUTTONUP: + _mousePos = event.mouse; + eventTarget()->rightButtonUp(_mousePos); + break; + case Common::EVENT_KEYDOWN: + eventTarget()->keyDown(event.kbd); + break; + case Common::EVENT_KEYUP: + eventTarget()->keyUp(event.kbd); + break; + default: + break; + } +} + +void Events::pollEventsAndWait() { + pollEvents(); + g_system->delayMillis(10); + + // Regularly update the sound mixer + CGameManager *gameManager = g_vm->_window->_gameManager; + if (gameManager) + gameManager->_sound.updateMixer(); +} + +bool Events::checkForNextFrameCounter() { + // Check for next game frame + uint32 milli = g_system->getMillis(); + if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) { + ++_frameCounter; + _priorFrameTime = milli; + + // Handle any idle updates + eventTarget()->onIdle(); + + // Give time to the debugger + _vm->_debugger->onFrame(); + + // Display the frame + _vm->_screen->update(); + + return true; + } + + return false; +} + +uint32 Events::getTicksCount() const { + return g_system->getMillis(); +} + +void Events::sleep(uint time) { + uint32 delayEnd = g_system->getMillis() + time; + + while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) + pollEventsAndWait(); +} + +bool Events::waitForPress(uint expiry) { + uint32 delayEnd = g_system->getMillis() + expiry; + + while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) { + g_system->delayMillis(10); + checkForNextFrameCounter(); + + Common::Event event; + if (g_system->getEventManager()->pollEvent(event)) { + switch (event.type) { + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_MBUTTONDOWN: + case Common::EVENT_KEYDOWN: + return true; + default: + break; + } + } + } + + return false; +} + +} // End of namespace Titanic diff --git a/engines/titanic/events.h b/engines/titanic/events.h new file mode 100644 index 0000000000..68666c7c46 --- /dev/null +++ b/engines/titanic/events.h @@ -0,0 +1,145 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EVENTS_H +#define TITANIC_EVENTS_H + +#include "common/scummsys.h" +#include "common/events.h" +#include "common/stack.h" +#include "support/rect.h" + +namespace Titanic { + +#define GAME_FRAME_RATE 30 +#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) +#define DOUBLE_CLICK_TIME 100 + +enum SpecialButtons { + MK_LBUTTON = 1, MK_RBUTTON = 2, MK_SHIFT = 4, MK_CONTROL = 8, + MK_MBUTTON = 0x10 +}; + +class TitanicEngine; + +/** + * A base class for windows that can receive event messages + */ +class CEventTarget { +public: + virtual ~CEventTarget() {} + + /** + * Called to handle any regular updates the game requires + */ + virtual void onIdle() {} + + /** + * Mouse/key event handlers + */ + virtual void mouseMove(const Point &mousePos) {} + virtual void leftButtonDown(const Point &mousePos) {} + virtual void leftButtonUp(const Point &mousePos) {} + virtual void leftButtonDoubleClick(const Point &mousePos) {} + virtual void middleButtonDown(const Point &mousePos) {} + virtual void middleButtonUp(const Point &mousePos) {} + virtual void middleButtonDoubleClick(const Point &mousePos) {} + virtual void rightButtonDown(const Point &mousePos) {} + virtual void rightButtonUp(const Point &mousePos) {} + virtual void keyDown(Common::KeyState keyState) {} + virtual void keyUp(Common::KeyState keyState) {} +}; + +class Events { +private: + TitanicEngine *_vm; + Common::Stack<CEventTarget *> _eventTargets; + uint32 _frameCounter; + uint32 _priorFrameTime; + Common::Point _mousePos; + + /** + * Check whether it's time to display the next screen frame + */ + bool checkForNextFrameCounter(); + + /** + * Return the currently active event target + */ + CEventTarget *eventTarget() const { + return _eventTargets.top(); + } +public: + Events(TitanicEngine *vm); + ~Events() {} + + /** + * Adds a new event target to the top of the list. It will get + * all events generated until such time as another is pushed on + * top of it, or the removeTarget method is called + */ + void addTarget(CEventTarget *target) { + _eventTargets.push(target); + } + + /** + * Removes the currently active event target + */ + void removeTarget() { + _eventTargets.pop(); + } + + /** + * Check for any pending events + */ + void pollEvents(); + + /** + * Poll for events and introduce a small delay, to allow the system to + * yield to other running programs + */ + void pollEventsAndWait(); + + /** + * Return the current game frame number + */ + uint32 getFrameCounter() const { return _frameCounter; } + + /** + * Get the elapsed playtime + */ + uint32 getTicksCount() const; + + /** + * Sleep for a specified period of time + */ + void sleep(uint time); + + /** + * Wait for a mouse or keypress + */ + bool waitForPress(uint expiry); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EVENTS_H */ diff --git a/engines/titanic/game/announce.cpp b/engines/titanic/game/announce.cpp new file mode 100644 index 0000000000..04e7a84271 --- /dev/null +++ b/engines/titanic/game/announce.cpp @@ -0,0 +1,133 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/announce.h" +#include "titanic/titanic.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAnnounce, CGameObject) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + +CAnnounce::CAnnounce() : _nameIndex(0), _soundHandle(0), _leaveFlag(1), _enabled(false) { +} + +void CAnnounce::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_nameIndex, indent); + file->writeNumberLine(_soundHandle, indent); + file->writeNumberLine(_leaveFlag, indent); + file->writeNumberLine(_enabled, indent); + + CGameObject::save(file, indent); +} + +void CAnnounce::load(SimpleFile *file) { + file->readNumber(); + _nameIndex = file->readNumber(); + _soundHandle = file->readNumber(); + _leaveFlag = file->readNumber(); + _enabled = file->readNumber(); + + CGameObject::load(file); +} + +bool CAnnounce::TimerMsg(CTimerMsg *msg) { + if (!_enabled) + return false; + + if (msg->_timerCtr == 1) { + CString numStr = "0"; + CString waveNames1[20] = { + "z#181.wav", "z#211.wav", "z#203.wav", "z#202.wav", "z#201.wav", + "z#200.wav", "z#199.wav", "z#198.wav", "z#197.wav", "z#196.wav", + "z#210.wav", "z#209.wav", "z#208.wav", "z#207.wav", "z#206.wav", + "z#205.wav", "z#204.wav", "z#145.wav", "", "" + }; + CString waveNames2[37] = { + "z#154.wav", "z#153.wav", "z#152.wav", "z#151.wav", "z#150.wav", + "z#149.wav", "z#148.wav", "z#169.wav", "z#171.wav", "z#178.wav", + "z#176.wav", "z#177.wav", "z#165.wav", "z#170.wav", "z#180.wav", + "z#156.wav", "z#172.wav", "z#173.wav", "z#160.wav", "z#158.wav", + "z#161.wav", "z#179.wav", "z#163.wav", "z#164.wav", "z#162.wav", + "z#159.wav", "z#175.wav", "z#166.wav", "z#174.wav", "z#157.wav", + "", "", "", "", "", "", "" + }; + + int randVal = _nameIndex ? g_vm->getRandomNumber(2) : 0; + switch (randVal) { + case 0: + case 1: + _soundHandle = playSound("z#189.wav"); + if (_nameIndex < 20) { + queueSound(waveNames1[_nameIndex], _soundHandle); + ++_nameIndex; + } else { + queueSound(waveNames1[1 + g_vm->getRandomNumber(17)], _soundHandle); + } + break; + + case 2: + _soundHandle = playSound("z#189.wav"); + queueSound(waveNames2[1 + g_vm->getRandomNumber(35)], _soundHandle); + break; + + default: + break; + } + + addTimer(1, 300000 + g_vm->getRandomNumber(30000), 0); + if (g_vm->getRandomNumber(3) == 0) + addTimer(2, 4000, 0); + + } else if (msg->_timerCtr == 2) { + CParrotSpeakMsg speakMsg; + speakMsg._value1 = "Announcements"; + speakMsg.execute("PerchedParrot"); + } + + return true; +} + +bool CAnnounce::LeaveRoomMsg(CLeaveRoomMsg *msg) { + if (_leaveFlag) { + addTimer(1, 1000, 0); + _leaveFlag = 0; + _enabled = true; + } + + return true; +} + +bool CAnnounce::ActMsg(CActMsg *msg) { + if (msg->_action == "Enable") + _enabled = true; + else if (msg->_action == "Disable") + _enabled = false; + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/announce.h b/engines/titanic/game/announce.h new file mode 100644 index 0000000000..9bf060daae --- /dev/null +++ b/engines/titanic/game/announce.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ANNOUNCE_H +#define TITANIC_ANNOUNCE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CAnnounce : public CGameObject { + DECLARE_MESSAGE_MAP; + bool TimerMsg(CTimerMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool ActMsg(CActMsg *msg); +private: + int _nameIndex; + int _soundHandle; + bool _leaveFlag; + bool _enabled; +public: + CLASSDEF; + CAnnounce(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ROOM_ITEM_H */ diff --git a/engines/titanic/game/annoy_barbot.cpp b/engines/titanic/game/annoy_barbot.cpp new file mode 100644 index 0000000000..8b22f9c13a --- /dev/null +++ b/engines/titanic/game/annoy_barbot.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/annoy_barbot.h" + +namespace Titanic { + +int CAnnoyBarbot::_v1; + +BEGIN_MESSAGE_MAP(CAnnoyBarbot, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + +void CAnnoyBarbot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + CGameObject::save(file, indent); +} + +void CAnnoyBarbot::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + CGameObject::load(file); +} + +bool CAnnoyBarbot::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if ((++_v1 % 3) == 1) { + CActMsg actMsg("GoRingBell"); + actMsg.execute("Barbot"); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/annoy_barbot.h b/engines/titanic/game/annoy_barbot.h new file mode 100644 index 0000000000..0ccfe43794 --- /dev/null +++ b/engines/titanic/game/annoy_barbot.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ANNOY_BARBOT_H +#define TITANIC_ANNOY_BARBOT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CAnnoyBarbot : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); +private: + static int _v1; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ANNOY_BARBOT_H */ diff --git a/engines/titanic/game/arb_background.cpp b/engines/titanic/game/arb_background.cpp new file mode 100644 index 0000000000..f71bcf90d1 --- /dev/null +++ b/engines/titanic/game/arb_background.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/arb_background.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CArbBackground, CBackground); + +CArbBackground::CArbBackground() : CBackground(), + _fieldE0(0), _fieldE4(61), _fieldE8(62), _fieldEC(118) { +} + +void CArbBackground::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); + + CBackground::save(file, indent); +} + +void CArbBackground::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/arb_background.h b/engines/titanic/game/arb_background.h new file mode 100644 index 0000000000..88d4d1bec6 --- /dev/null +++ b/engines/titanic/game/arb_background.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ARB_BACKGROUND_H +#define TITANIC_ARB_BACKGROUND_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CArbBackground : public CBackground { + DECLARE_MESSAGE_MAP; +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; +public: + CLASSDEF; + CArbBackground(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ARB_BACKGROUND_H */ diff --git a/engines/titanic/game/arboretum_gate.cpp b/engines/titanic/game/arboretum_gate.cpp new file mode 100644 index 0000000000..1f92f56acb --- /dev/null +++ b/engines/titanic/game/arboretum_gate.cpp @@ -0,0 +1,331 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/arboretum_gate.h" +#include "titanic/titanic.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CArboretumGate, CBackground) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(TurnOn) +END_MESSAGE_MAP() + +int CArboretumGate::_v1; +int CArboretumGate::_initialFrame; +int CArboretumGate::_v3; + +CArboretumGate::CArboretumGate() : CBackground() { + _viewName1 = "NULL"; + _viewName2 = "NULL"; + _seasonNum = 0; + _fieldF0 = 0; + _winterOffStartFrame = 244; + _winterOffEndFrame = 304; + _springOffStartFrame = 122; + _springOffEndFrame = 182; + _summerOffStartFrame1 = 183; + _summerOffEndFrame1 = 243; + _summerOffStartFrame2 = 665; + _summerOffEndFrame2 = 724; + _autumnOffStartFrame1 = 61; + _autumnOffEndFrame1 = 121; + _autumnOffStartFrame2 = 0; + _autumnOffEndFrame2 = 60; + _winterOnStartFrame = 485; + _winterOnEndFrame = 544; + _springOnStartFrame = 425; + _springOnEndFrame = 484; + _summerOnStartFrame1 = 545; + _summerOnEndFrame1 = 604; + _summerOnStartFrame2 = 605; + _summerOnEndFrame2 = 664; + _autumnOnStartFrame1 = 305; + _autumnOnEndFrame1 = 364; + _autumnOnStartFrame2 = 365; + _autumnOnEndFrame2 = 424; +} + +void CArboretumGate::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_seasonNum, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_initialFrame, indent); + file->writeNumberLine(_v3, indent); + file->writeQuotedLine(_viewName1, indent); + file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_winterOffStartFrame, indent); + file->writeNumberLine(_winterOffEndFrame, indent); + file->writeNumberLine(_springOffStartFrame, indent); + file->writeNumberLine(_springOffEndFrame, indent); + file->writeNumberLine(_summerOffStartFrame1, indent); + file->writeNumberLine(_summerOffEndFrame1, indent); + file->writeNumberLine(_summerOffStartFrame2, indent); + file->writeNumberLine(_summerOffEndFrame2, indent); + file->writeNumberLine(_autumnOffStartFrame1, indent); + file->writeNumberLine(_autumnOffEndFrame1, indent); + file->writeNumberLine(_autumnOffStartFrame2, indent); + file->writeNumberLine(_autumnOffEndFrame2, indent); + file->writeNumberLine(_winterOnStartFrame, indent); + file->writeNumberLine(_winterOnEndFrame, indent); + file->writeNumberLine(_springOnStartFrame, indent); + file->writeNumberLine(_springOnEndFrame, indent); + file->writeNumberLine(_summerOnStartFrame1, indent); + file->writeNumberLine(_summerOnEndFrame1, indent); + file->writeNumberLine(_summerOnStartFrame2, indent); + file->writeNumberLine(_summerOnEndFrame2, indent); + file->writeNumberLine(_autumnOnStartFrame1, indent); + file->writeNumberLine(_autumnOnEndFrame1, indent); + file->writeNumberLine(_autumnOnStartFrame2, indent); + file->writeNumberLine(_autumnOnEndFrame2, indent); + file->writeQuotedLine(_viewName2, indent); + + CBackground::save(file, indent); +} + +void CArboretumGate::load(SimpleFile *file) { + file->readNumber(); + _seasonNum = file->readNumber(); + _v1 = file->readNumber(); + _initialFrame = file->readNumber(); + _v3 = file->readNumber(); + _viewName1 = file->readString(); + _fieldF0 = file->readNumber(); + _winterOffStartFrame = file->readNumber(); + _winterOffEndFrame = file->readNumber(); + _springOffStartFrame = file->readNumber(); + _springOffEndFrame = file->readNumber(); + _summerOffStartFrame1 = file->readNumber(); + _summerOffEndFrame1 = file->readNumber(); + _summerOffStartFrame2 = file->readNumber(); + _summerOffEndFrame2 = file->readNumber(); + _autumnOffStartFrame1 = file->readNumber(); + _autumnOffEndFrame1 = file->readNumber(); + _autumnOffStartFrame2 = file->readNumber(); + _autumnOffEndFrame2 = file->readNumber(); + _winterOnStartFrame = file->readNumber(); + _winterOnEndFrame = file->readNumber(); + _springOnStartFrame = file->readNumber(); + _springOnEndFrame = file->readNumber(); + _summerOnStartFrame1 = file->readNumber(); + _summerOnEndFrame1 = file->readNumber(); + _summerOnStartFrame2 = file->readNumber(); + _summerOnEndFrame2 = file->readNumber(); + _autumnOnStartFrame1 = file->readNumber(); + _autumnOnEndFrame1 = file->readNumber(); + _autumnOnStartFrame2 = file->readNumber(); + _autumnOnEndFrame2 = file->readNumber(); + _viewName2 = file->readString(); + + CBackground::load(file); +} + +bool CArboretumGate::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _seasonNum = (_seasonNum + 1) % 4; + return true; +} + +bool CArboretumGate::ActMsg(CActMsg *msg) { + if (msg->_action == "PlayerGetsSpeechCentre") { + _v1 = 1; + CVisibleMsg visibleMsg(true); + visibleMsg.execute("SpCtrOverlay"); + } else if (msg->_action == "ExitLFrozen") { + if (_v3) { + _viewName2 = "FrozenArboretum.Node 2.W"; + CTurnOn onMsg; + onMsg.execute(this); + } else { + changeView("FrozenArboretum.Node 2.W"); + } + } else if (msg->_action == "ExitRFrozen") { + if (_v3) { + _viewName2 = "FrozenArboretum.Node 2.E"; + CTurnOn onMsg; + onMsg.execute(this); + } else { + changeView("FrozenArboretum.Node 2.E"); + } + } else if (msg->_action == "ExitLNormal") { + if (_v3) { + _viewName2 = "Arboretum.Node 2.W"; + CTurnOn onMsg; + onMsg.execute(this); + } else { + changeView("Arboretum.Node 2.W"); + } + } else if (msg->_action == "ExitRNormal") { + if (_v3) { + _viewName2 = "Arboretum.Node 2.E"; + CTurnOn onMsg; + onMsg.execute(this); + } + else { + changeView("Arboretum.Node 2.E"); + } + } + + return true; +} + +bool CArboretumGate::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(!_v3); + + if (_viewName1 != "NULL") { + changeView(_viewName1); + } else if (_viewName2 != "NULL") { + changeView(_viewName2); + _viewName2 = "NULL"; + } + + return true; +} + +bool CArboretumGate::LeaveViewMsg(CLeaveViewMsg *msg) { + return false; +} + +bool CArboretumGate::TurnOff(CTurnOff *msg) { + if (!_v3) { + switch (_seasonNum) { + case SPRING: + playMovie(_springOffStartFrame, _springOffEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + break; + + case SUMMER: + if (_v1) { + playMovie(_summerOffStartFrame2, _summerOffEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } else { + playMovie(_summerOffStartFrame1, _summerOffEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } + break; + + case AUTUMN: + if (_v1) { + playMovie(_autumnOffStartFrame2, _autumnOffEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } else { + playMovie(_autumnOffStartFrame1, _autumnOffEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } + break; + + case WINTER: + playMovie(_winterOffStartFrame, _winterOffEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + break; + + default: + break; + } + + _v3 = 1; + CArboretumGateMsg gateMsg; + gateMsg.execute("Arboretum", nullptr, MSGFLAG_SCAN); + } + + return true; +} + +bool CArboretumGate::TurnOn(CTurnOn *msg) { + if (_v3) { + CArboretumGateMsg gateMsg(0); + gateMsg.execute("Arboretum"); + setVisible(true); + + switch (_seasonNum) { + case SPRING: + playMovie(_springOnStartFrame, _springOnEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + break; + + case SUMMER: + if (_v1) { + playMovie(_summerOnStartFrame2, _summerOnEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } else { + playMovie(_summerOnStartFrame1, _summerOnEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } + break; + + case AUTUMN: + if (_v1) { + playMovie(_autumnOnStartFrame2, _autumnOnEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } else { + playMovie(_autumnOnStartFrame1, _autumnOnEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + } + break; + + case WINTER: + playMovie(_winterOnStartFrame, _winterOnEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + break; + + default: + break; + } + + _v3 = 0; + } + + return true; +} + +bool CArboretumGate::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_v3) { + CTurnOff offMsg; + offMsg.execute(this); + } + + return true; +} + +bool CArboretumGate::EnterViewMsg(CEnterViewMsg *msg) { + if (!_v3) { + switch (_seasonNum) { + case SPRING: + _initialFrame = _springOffStartFrame; + break; + + case SUMMER: + _initialFrame = _v1 ? _summerOffStartFrame2 : _summerOffStartFrame1; + break; + + case AUTUMN: + _initialFrame = _v1 ? _autumnOffStartFrame1 : _autumnOffStartFrame2; + break; + + case WINTER: + _initialFrame = _winterOffStartFrame; + break; + + default: + break; + } + + loadFrame(_initialFrame); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/arboretum_gate.h b/engines/titanic/game/arboretum_gate.h new file mode 100644 index 0000000000..62c9200a64 --- /dev/null +++ b/engines/titanic/game/arboretum_gate.h @@ -0,0 +1,92 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ARBORETUM_GATE_H +#define TITANIC_ARBORETUM_GATE_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CArboretumGate : public CBackground { + DECLARE_MESSAGE_MAP; + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool ActMsg(CActMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool TurnOff(CTurnOff *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool TurnOn(CTurnOn *msg); +private: + static int _v1; + static int _initialFrame; + static int _v3; +private: + int _seasonNum; + CString _viewName1; + int _fieldF0; + int _winterOffStartFrame; + int _winterOffEndFrame; + int _springOffStartFrame; + int _springOffEndFrame; + int _summerOffStartFrame2; + int _summerOffEndFrame2; + int _summerOffStartFrame1; + int _summerOffEndFrame1; + int _autumnOffStartFrame2; + int _autumnOffEndFrame2; + int _autumnOffStartFrame1; + int _autumnOffEndFrame1; + int _winterOnStartFrame; + int _winterOnEndFrame; + int _springOnStartFrame; + int _springOnEndFrame; + int _summerOnStartFrame1; + int _summerOnEndFrame1; + int _summerOnStartFrame2; + int _summerOnEndFrame2; + int _autumnOnStartFrame1; + int _autumnOnEndFrame1; + int _autumnOnStartFrame2; + int _autumnOnEndFrame2; + CString _viewName2; +public: + CLASSDEF; + CArboretumGate(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ARBORETUM_GATE_H */ diff --git a/engines/titanic/game/auto_animate.cpp b/engines/titanic/game/auto_animate.cpp new file mode 100644 index 0000000000..16e6e56747 --- /dev/null +++ b/engines/titanic/game/auto_animate.cpp @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/auto_animate.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAutoAnimate, CBackground) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(InitializeAnimMsg) +END_MESSAGE_MAP() + +void CAutoAnimate::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_enabled, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_repeat, indent); + CBackground::save(file, indent); +} + +void CAutoAnimate::load(SimpleFile *file) { + file->readNumber(); + _enabled = file->readNumber(); + _fieldE4 = file->readNumber(); + _repeat = file->readNumber(); + CBackground::load(file); +} + +bool CAutoAnimate::EnterViewMsg(CEnterViewMsg *msg) { + if (_enabled) { + uint flags = _repeat ? MOVIE_REPEAT : 0; + if (_startFrame != _endFrame) + playMovie(_startFrame, _endFrame, flags); + else + playMovie(flags); + + if (!_fieldE4) + _enabled = false; + } + + return true; +} + +bool CAutoAnimate::InitializeAnimMsg(CInitializeAnimMsg *msg) { + _enabled = true; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/auto_animate.h b/engines/titanic/game/auto_animate.h new file mode 100644 index 0000000000..735aba922e --- /dev/null +++ b/engines/titanic/game/auto_animate.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AUTO_ANIMATE_H +#define TITANIC_AUTO_ANIMATE_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CAutoAnimate : public CBackground { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool InitializeAnimMsg(CInitializeAnimMsg *msg); +private: + bool _enabled; + int _fieldE4; + bool _repeat; +public: + CLASSDEF; + CAutoAnimate() : CBackground(), _enabled(true), _fieldE4(1), _repeat(false) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AUTO_ANIMATE_H */ diff --git a/engines/titanic/game/bar_bell.cpp b/engines/titanic/game/bar_bell.cpp new file mode 100644 index 0000000000..207644a00e --- /dev/null +++ b/engines/titanic/game/bar_bell.cpp @@ -0,0 +1,131 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bar_bell.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CBarBell, CGameObject) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + +CBarBell::CBarBell() : CGameObject(), _fieldBC(0), + _volume(65), _soundVal3(0), _fieldC8(0), _fieldCC(0) { +} + +void CBarBell::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_volume, indent); + file->writeNumberLine(_soundVal3, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + + CGameObject::save(file, indent); +} + +void CBarBell::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _volume = file->readNumber(); + _soundVal3 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + + CGameObject::load(file); +} + +bool CBarBell::EnterRoomMsg(CEnterRoomMsg *msg) { + _fieldBC = 0; + return true; +} + +bool CBarBell::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if ((_fieldC8 % 3) == 2) { + switch (_fieldBC) { + case 0: + case 1: + case 5: + playSound("c#54.wav", _volume, _soundVal3); + break; + + case 2: + playSound("c#52.wav", _volume, _soundVal3); + break; + + case 3: + playSound("c#53.wav", _volume, _soundVal3); + break; + + case 4: + playSound("c#55.wav", _volume, _soundVal3); + break; + + default: + playSound("c#51.wav", _volume, _soundVal3); + break; + } + } else if (_fieldBC >= 5) { + if (_fieldBC == 6) { + CActMsg actMsg("BellRing3"); + actMsg.execute("Barbot"); + } + + playSound("c#51.wav", _volume, _soundVal3); + } else { + if (_fieldBC == 3) { + CActMsg actMsg("BellRing1"); + actMsg.execute("Barbot"); + } else if (_fieldBC == 4) { + CActMsg actMsg("BellRing2"); + actMsg.execute("Barbot"); + } + + playSound("c#54.wav", _volume, _soundVal3); + } + + return true; +} + +bool CBarBell::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!_fieldBC) { + CTurnOn onMsg; + onMsg.execute("Barbot"); + } + + ++_fieldBC; + return 2; +} + +bool CBarBell::ActMsg(CActMsg *msg) { + if (msg->_action == "ResetCount") { + _fieldBC = 0; + ++_fieldC8; + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bar_bell.h b/engines/titanic/game/bar_bell.h new file mode 100644 index 0000000000..b50fe505ba --- /dev/null +++ b/engines/titanic/game/bar_bell.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BAR_BELL_H +#define TITANIC_BAR_BELL_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CBarBell : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool ActMsg(CActMsg *msg); +public: + int _fieldBC; + int _volume; + int _soundVal3; + int _fieldC8; + int _fieldCC; +public: + CLASSDEF; + CBarBell(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BAR_BELL_H */ diff --git a/engines/titanic/game/bar_menu.cpp b/engines/titanic/game/bar_menu.cpp new file mode 100644 index 0000000000..b24c429c9b --- /dev/null +++ b/engines/titanic/game/bar_menu.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bar_menu.h" + +namespace Titanic { + +CBarMenu::CBarMenu() : CGameObject(), _fieldBC(0), _fieldC0(0), _fieldC4(6) { +} + +void CBarMenu::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + + CGameObject::save(file, indent); +} + +void CBarMenu::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bar_menu.h b/engines/titanic/game/bar_menu.h new file mode 100644 index 0000000000..84c0219084 --- /dev/null +++ b/engines/titanic/game/bar_menu.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BAR_MENU_H +#define TITANIC_BAR_MENU_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBarMenu : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; +public: + CLASSDEF; + CBarMenu(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BAR_MENU_H */ diff --git a/engines/titanic/game/bar_menu_button.cpp b/engines/titanic/game/bar_menu_button.cpp new file mode 100644 index 0000000000..f57d72c64a --- /dev/null +++ b/engines/titanic/game/bar_menu_button.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bar_menu_button.h" + +namespace Titanic { + +void CBarMenuButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CBarMenuButton::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bar_menu_button.h b/engines/titanic/game/bar_menu_button.h new file mode 100644 index 0000000000..c666df413b --- /dev/null +++ b/engines/titanic/game/bar_menu_button.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BAR_MENU_BUTTON_H +#define TITANIC_BAR_MENU_BUTTON_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBarMenuButton : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CBarMenuButton() : CGameObject(), _value(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BAR_MENU_BUTTON_H */ diff --git a/engines/titanic/game/belbot_get_light.cpp b/engines/titanic/game/belbot_get_light.cpp new file mode 100644 index 0000000000..3e678a8a0c --- /dev/null +++ b/engines/titanic/game/belbot_get_light.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/belbot_get_light.h" + +namespace Titanic { + +void CBelbotGetLight::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_value, indent); + CGameObject::save(file, indent); +} + +void CBelbotGetLight::load(SimpleFile *file) { + file->readNumber(); + _value = file->readString(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/belbot_get_light.h b/engines/titanic/game/belbot_get_light.h new file mode 100644 index 0000000000..a3aa0f737e --- /dev/null +++ b/engines/titanic/game/belbot_get_light.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BELBOT_GET_LIGHT_H +#define TITANIC_BELBOT_GET_LIGHT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBelbotGetLight : public CGameObject { +private: + CString _value; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIGHT_H */ diff --git a/engines/titanic/game/bilge_succubus.cpp b/engines/titanic/game/bilge_succubus.cpp new file mode 100644 index 0000000000..ceee3f7740 --- /dev/null +++ b/engines/titanic/game/bilge_succubus.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bilge_succubus.h" + +namespace Titanic { + +CBilgeSuccUBus::CBilgeSuccUBus() : CSuccUBus(), _field1DC(0), + _field1E0(0), _field1E4(0), _field1E8(0) { +} + +void CBilgeSuccUBus::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field1DC, indent); + file->writeNumberLine(_field1E0, indent); + file->writeNumberLine(_field1E4, indent); + file->writeNumberLine(_field1E8, indent); + + CSuccUBus::save(file, indent); +} + +void CBilgeSuccUBus::load(SimpleFile *file) { + file->readNumber(); + _field1DC = file->readNumber(); + _field1E0 = file->readNumber(); + _field1E4 = file->readNumber(); + _field1E8 = file->readNumber(); + + CSuccUBus::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bilge_succubus.h b/engines/titanic/game/bilge_succubus.h new file mode 100644 index 0000000000..4b2a626dc2 --- /dev/null +++ b/engines/titanic/game/bilge_succubus.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BILGE_SUCCUBUS_H +#define TITANIC_BILGE_SUCCUBUS_H + +#include "titanic/npcs/succubus.h" + +namespace Titanic { + +class CBilgeSuccUBus : public CSuccUBus { +public: + int _field1DC; + int _field1E0; + int _field1E4; + int _field1E8; +public: + CLASSDEF; + CBilgeSuccUBus(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BILGE_SUCCUBUS_H */ diff --git a/engines/titanic/game/bomb.cpp b/engines/titanic/game/bomb.cpp new file mode 100644 index 0000000000..9a08f26ece --- /dev/null +++ b/engines/titanic/game/bomb.cpp @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bomb.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CBomb::CBomb() : CBackground() { + _fieldE0 = 0; + _fieldE4 = 0; + _fieldE8 = 17; + _fieldEC = 9; + _fieldF0 = 0; + _fieldF4 = 999; + _fieldF8 = 0; + _fieldFC = 0; + _startingTicks = 0; + _field104 = 60; +} + +void CBomb::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(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_startingTicks, indent); + file->writeNumberLine(_field104, indent); + + CBackground::save(file, indent); +} + +void CBomb::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + _startingTicks = file->readNumber(); + _field104 = file->readNumber(); + + CBackground::load(file); +} + +bool CBomb::EnterRoomMsg(CEnterRoomMsg *msg) { + _fieldE8 = 12; + _fieldEC = 9; + _fieldF0 = 0; + _startingTicks = g_vm->_events->getTicksCount(); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bomb.h b/engines/titanic/game/bomb.h new file mode 100644 index 0000000000..ab4df16db0 --- /dev/null +++ b/engines/titanic/game/bomb.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BOMB_H +#define TITANIC_BOMB_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CBomb : public CBackground { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; + int _fieldF4; + int _fieldF8; + int _fieldFC; + int _startingTicks; + int _field104; +public: + CLASSDEF; + CBomb(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BOMB_H */ diff --git a/engines/titanic/game/bottom_of_well_monitor.cpp b/engines/titanic/game/bottom_of_well_monitor.cpp new file mode 100644 index 0000000000..beb2a80ce9 --- /dev/null +++ b/engines/titanic/game/bottom_of_well_monitor.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bottom_of_well_monitor.h" + +namespace Titanic { + +int CBottomOfWellMonitor::_v1; +int CBottomOfWellMonitor::_v2; + +void CBottomOfWellMonitor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CBottomOfWellMonitor::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bottom_of_well_monitor.h b/engines/titanic/game/bottom_of_well_monitor.h new file mode 100644 index 0000000000..65424aad70 --- /dev/null +++ b/engines/titanic/game/bottom_of_well_monitor.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BOTTOM_OF_WELL_MONITOR_H +#define TITANIC_BOTTOM_OF_WELL_MONITOR_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBottomOfWellMonitor : public CGameObject { +public: + static int _v1, _v2; + int _value; +public: + CLASSDEF; + CBottomOfWellMonitor() : _value(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BOTTOM_OF_WELL_MONITOR_H */ diff --git a/engines/titanic/game/bowl_unlocker.cpp b/engines/titanic/game/bowl_unlocker.cpp new file mode 100644 index 0000000000..c3c501dbd6 --- /dev/null +++ b/engines/titanic/game/bowl_unlocker.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bowl_unlocker.h" + +namespace Titanic { + +void CBowlUnlocker::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CBowlUnlocker::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bowl_unlocker.h b/engines/titanic/game/bowl_unlocker.h new file mode 100644 index 0000000000..2559ac2c52 --- /dev/null +++ b/engines/titanic/game/bowl_unlocker.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BOWL_UNLOCKER_H +#define TITANIC_BOWL_UNLOCKER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBowlUnlocker : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CBowlUnlocker() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BOWL_UNLOCKER_H */ diff --git a/engines/titanic/game/brain_slot.cpp b/engines/titanic/game/brain_slot.cpp new file mode 100644 index 0000000000..f1963142ac --- /dev/null +++ b/engines/titanic/game/brain_slot.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/brain_slot.h" + +namespace Titanic { + +int CBrainSlot::_v1; +int CBrainSlot::_v2; + +void CBrainSlot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeQuotedLine(_value2, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + + CGameObject::save(file, indent); +} + +void CBrainSlot::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readString(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/brain_slot.h b/engines/titanic/game/brain_slot.h new file mode 100644 index 0000000000..94b6d7f227 --- /dev/null +++ b/engines/titanic/game/brain_slot.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BRAIN_SLOT_H +#define TITANIC_BRAIN_SLOT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBrainSlot : public CGameObject { +public: + static int _v1, _v2; +public: + int _value1; + CString _value2; +public: + CLASSDEF; + CBrainSlot() : CGameObject(), _value1(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BRAIN_SLOT_H */ diff --git a/engines/titanic/game/bridge_door.cpp b/engines/titanic/game/bridge_door.cpp new file mode 100644 index 0000000000..57cdbd23ad --- /dev/null +++ b/engines/titanic/game/bridge_door.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bridge_door.h" + +namespace Titanic { + +void CBridgeDoor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CBridgeDoor::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bridge_door.h b/engines/titanic/game/bridge_door.h new file mode 100644 index 0000000000..c1872a29be --- /dev/null +++ b/engines/titanic/game/bridge_door.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BRIDGE_DOOR_H +#define TITANIC_BRIDGE_DOOR_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBridgeDoor : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BRIDGE_DOOR_H */ diff --git a/engines/titanic/game/bridge_view.cpp b/engines/titanic/game/bridge_view.cpp new file mode 100644 index 0000000000..9854969494 --- /dev/null +++ b/engines/titanic/game/bridge_view.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/bridge_view.h" + +namespace Titanic { + +void CBridgeView::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + CBackground::save(file, indent); +} + +void CBridgeView::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/bridge_view.h b/engines/titanic/game/bridge_view.h new file mode 100644 index 0000000000..d7c7c35aa9 --- /dev/null +++ b/engines/titanic/game/bridge_view.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BRIDGE_VIEW_H +#define TITANIC_BRIDGE_VIEW_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CBridgeView : public CBackground { +public: + int _fieldE0; +public: + CLASSDEF; + CBridgeView() : CBackground(), _fieldE0(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BRIDGE_VIEW_H */ diff --git a/engines/titanic/game/broken_pell_base.cpp b/engines/titanic/game/broken_pell_base.cpp new file mode 100644 index 0000000000..59e2b9bca1 --- /dev/null +++ b/engines/titanic/game/broken_pell_base.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/broken_pell_base.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CBrokenPellBase, CBackground); + +int CBrokenPellBase::_v1; +int CBrokenPellBase::_v2; + +void CBrokenPellBase::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_fieldE0, indent); + CBackground::save(file, indent); +} + +void CBrokenPellBase::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _fieldE0 = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/broken_pell_base.h b/engines/titanic/game/broken_pell_base.h new file mode 100644 index 0000000000..f63cd0112b --- /dev/null +++ b/engines/titanic/game/broken_pell_base.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BROKEN_PELL_BASE_H +#define TITANIC_BROKEN_PELL_BASE_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CBrokenPellBase : public CBackground { + DECLARE_MESSAGE_MAP; +private: + static int _v1; + static int _v2; + + int _fieldE0; +public: + CLASSDEF; + CBrokenPellBase() : CBackground(), _fieldE0(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BROKEN_PELL_BASE_H */ diff --git a/engines/titanic/game/broken_pellerator.cpp b/engines/titanic/game/broken_pellerator.cpp new file mode 100644 index 0000000000..d3b204b1e5 --- /dev/null +++ b/engines/titanic/game/broken_pellerator.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/broken_pellerator.h" + +namespace Titanic { + +void CBrokenPellerator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string3, indent); + file->writeQuotedLine(_string4, indent); + file->writeQuotedLine(_string5, indent); + + CBrokenPellBase::save(file, indent); +} + +void CBrokenPellerator::load(SimpleFile *file) { + file->readNumber(); + _string2 = file->readString(); + _string3 = file->readString(); + _string4 = file->readString(); + _string5 = file->readString(); + + CBrokenPellBase::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/broken_pellerator.h b/engines/titanic/game/broken_pellerator.h new file mode 100644 index 0000000000..6fbde91053 --- /dev/null +++ b/engines/titanic/game/broken_pellerator.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BROKEN_PELLERATOR_H +#define TITANIC_BROKEN_PELLERATOR_H + +#include "titanic/game/broken_pell_base.h" + +namespace Titanic { + +class CBrokenPellerator : public CBrokenPellBase { +private: + CString _string2; + CString _string3; + CString _string4; + CString _string5; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BROKEN_PELLERATOR_H */ diff --git a/engines/titanic/game/broken_pellerator_froz.cpp b/engines/titanic/game/broken_pellerator_froz.cpp new file mode 100644 index 0000000000..4b21ea93d0 --- /dev/null +++ b/engines/titanic/game/broken_pellerator_froz.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/broken_pellerator_froz.h" + +namespace Titanic { + +void CBrokenPelleratorFroz::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string3, indent); + file->writeQuotedLine(_string4, indent); + file->writeQuotedLine(_string5, indent); + + CBrokenPellBase::save(file, indent); +} + +void CBrokenPelleratorFroz::load(SimpleFile *file) { + file->readNumber(); + _string2 = file->readString(); + _string3 = file->readString(); + _string4 = file->readString(); + _string5 = file->readString(); + + CBrokenPellBase::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/broken_pellerator_froz.h b/engines/titanic/game/broken_pellerator_froz.h new file mode 100644 index 0000000000..1df6d2d0b2 --- /dev/null +++ b/engines/titanic/game/broken_pellerator_froz.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BROKEN_PELLERATOR_FROZ_H +#define TITANIC_BROKEN_PELLERATOR_FROZ_H + +#include "titanic/game/broken_pell_base.h" + +namespace Titanic { + +class CBrokenPelleratorFroz : public CBrokenPellBase { +private: + CString _string2; + CString _string3; + CString _string4; + CString _string5; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BROKEN_PELLERATOR_FROZ_H */ diff --git a/engines/titanic/game/cage.cpp b/engines/titanic/game/cage.cpp new file mode 100644 index 0000000000..7fbc052278 --- /dev/null +++ b/engines/titanic/game/cage.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/cage.h" + +namespace Titanic { + +int CCage::_v1; +int CCage::_v2; + +void CCage::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + + CBackground::save(file, indent); +} + +void CCage::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/cage.h b/engines/titanic/game/cage.h new file mode 100644 index 0000000000..bbce978489 --- /dev/null +++ b/engines/titanic/game/cage.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CAGE_H +#define TITANIC_CAGE_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CCage : public CBackground { +public: + static int _v1; + static int _v2; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CAGE_H */ diff --git a/engines/titanic/game/call_pellerator.cpp b/engines/titanic/game/call_pellerator.cpp new file mode 100644 index 0000000000..0ea48131b1 --- /dev/null +++ b/engines/titanic/game/call_pellerator.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/call_pellerator.h" + +namespace Titanic { + +void CCallPellerator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CCallPellerator::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/call_pellerator.h b/engines/titanic/game/call_pellerator.h new file mode 100644 index 0000000000..7da4b40794 --- /dev/null +++ b/engines/titanic/game/call_pellerator.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CALL_PELLERATOR_H +#define TITANIC_CALL_PELLERATOR_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CCallPellerator : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CALL_PELLERATOR_H */ diff --git a/engines/titanic/game/captains_wheel.cpp b/engines/titanic/game/captains_wheel.cpp new file mode 100644 index 0000000000..c84c9194ce --- /dev/null +++ b/engines/titanic/game/captains_wheel.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/captains_wheel.h" + +namespace Titanic { + +CCaptainsWheel::CCaptainsWheel() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0), + _fieldF0(0), _fieldF4(0) { +} + +void CCaptainsWheel::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(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + + CBackground::save(file, indent); +} + +void CCaptainsWheel::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/captains_wheel.h b/engines/titanic/game/captains_wheel.h new file mode 100644 index 0000000000..549dcbe685 --- /dev/null +++ b/engines/titanic/game/captains_wheel.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CAPTAINS_WHEEL_H +#define TITANIC_CAPTAINS_WHEEL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CCaptainsWheel : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; + int _fieldF4; +public: + CLASSDEF; + CCaptainsWheel(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CAPTAINS_WHEEL_H */ diff --git a/engines/titanic/game/cdrom.cpp b/engines/titanic/game/cdrom.cpp new file mode 100644 index 0000000000..cd913d05f7 --- /dev/null +++ b/engines/titanic/game/cdrom.cpp @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/cdrom.h" +#include "titanic/core/room_item.h" +#include "titanic/game/cdrom_tray.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CCDROM, CGameObject) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(MouseDragEndMsg) + ON_MESSAGE(MouseDragMoveMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + +CCDROM::CCDROM() : CGameObject() { +} + +void CCDROM::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writePoint(_tempPos, indent); + CGameObject::save(file, indent); +} + +void CCDROM::load(SimpleFile *file) { + file->readNumber(); + _tempPos = file->readPoint(); + CGameObject::load(file); +} + +bool CCDROM::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (checkStartDragging(msg)) { + _tempPos = msg->_mousePos - _bounds; + setPosition(msg->_mousePos - _tempPos); + return true; + } else { + return false; + } +} + +bool CCDROM::MouseDragEndMsg(CMouseDragEndMsg *msg) { + if (msg->_dropTarget && msg->_dropTarget->getName() == "newComputer") { + CCDROMTray *newTray = dynamic_cast<CCDROMTray *>(getRoom()->findByName("newTray")); + + if (newTray->_isOpened && newTray->_insertedCD == "None") { + CActMsg actMsg(getName()); + actMsg.execute(newTray); + setVisible(false); + } + } + + resetPosition(); + return true; +} + +bool CCDROM::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + setPosition(msg->_mousePos - _tempPos); + return true; +} + +bool CCDROM::ActMsg(CActMsg *msg) { + if (msg->_action == "Ejected") + setVisible(true); + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/cdrom.h b/engines/titanic/game/cdrom.h new file mode 100644 index 0000000000..017914830c --- /dev/null +++ b/engines/titanic/game/cdrom.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CDROM_H +#define TITANIC_CDROM_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CCDROM : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + bool ActMsg(CActMsg *msg); +private: + Point _tempPos; +public: + CLASSDEF; + CCDROM(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CDROM_H */ diff --git a/engines/titanic/game/cdrom_computer.cpp b/engines/titanic/game/cdrom_computer.cpp new file mode 100644 index 0000000000..ceb0595188 --- /dev/null +++ b/engines/titanic/game/cdrom_computer.cpp @@ -0,0 +1,78 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/cdrom_computer.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CCDROMComputer, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + +CCDROMComputer::CCDROMComputer() : CGameObject(), + _clickRect(0, 3, 55, 32) { +} + +void CCDROMComputer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_clickRect.left, indent); + file->writeNumberLine(_clickRect.top, indent); + file->writeNumberLine(_clickRect.right, indent); + file->writeNumberLine(_clickRect.bottom, indent); + + CGameObject::save(file, indent); +} + +void CCDROMComputer::load(SimpleFile *file) { + file->readNumber(); + _clickRect.left = file->readNumber(); + _clickRect.top = file->readNumber(); + _clickRect.right = file->readNumber(); + _clickRect.bottom = file->readNumber(); + + CGameObject::load(file); +} + +bool CCDROMComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTreeItem *tray = getRoom()->findByName("newTray"); + if (tray) { + CStatusChangeMsg statusMsg; + statusMsg.execute(tray); + + if (!statusMsg._success) { + // Check if the mouse is within the clickable area + Rect tempRect = _clickRect; + tempRect.translate(_bounds.left, _bounds.top); + + if (!tempRect.contains(msg->_mousePos)) + return true; + } + + CActMsg actMsg("ClickedOn"); + actMsg.execute(tray); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/cdrom_computer.h b/engines/titanic/game/cdrom_computer.h new file mode 100644 index 0000000000..39fa9b9498 --- /dev/null +++ b/engines/titanic/game/cdrom_computer.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CDROM_COMPUTER_H +#define TITANIC_CDROM_COMPUTER_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CCDROMComputer : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); +private: + Rect _clickRect; +public: + CLASSDEF; + CCDROMComputer(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CDROM_COMPUTER_H */ diff --git a/engines/titanic/game/cdrom_tray.cpp b/engines/titanic/game/cdrom_tray.cpp new file mode 100644 index 0000000000..1e5b135d35 --- /dev/null +++ b/engines/titanic/game/cdrom_tray.cpp @@ -0,0 +1,127 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/core/room_item.h" +#include "titanic/game/cdrom_tray.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CCDROMTray, CGameObject) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(StatusChangeMsg) +END_MESSAGE_MAP() + + +CCDROMTray::CCDROMTray() : CGameObject(), _isOpened(false) { +} + +void CCDROMTray::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_isOpened, indent); + file->writeQuotedLine(_insertedCD, indent); + + CGameObject::save(file, indent); +} + +void CCDROMTray::load(SimpleFile *file) { + file->readNumber(); + _isOpened = file->readNumber(); + _insertedCD = file->readString(); + + CGameObject::load(file); +} + +bool CCDROMTray::ActMsg(CActMsg *msg) { + if (msg->_action == "ClickedOn") { + if (_isOpened) { + // Closing the tray + if (_insertedCD == "None") { + // No CD in tray + playMovie(55, 65, 0); + playSound("a#35.wav", 50, 0, 0); + _isOpened = false; + } else { + // Ejecting tray with CD + CTreeItem *cdrom = getRoom()->findByName(_insertedCD); + if (cdrom) { + CActMsg actMsg("Ejected"); + actMsg.execute(cdrom); + } + + _insertedCD = "None"; + loadFrame(52); + } + } else if (_insertedCD == "None") { + // Opening tray with no CD + playMovie(44, 54, 0); + playSound("a#34.wav", 50, 0, 0); + _isOpened = true; + } else if (_insertedCD == "newCD1" || _insertedCD == "newCD2") { + // Opening tray with standard CD + playMovie(22, 32, 0); + playSound("a#34.wav", 50, 0, 0); + _isOpened = true; + } else if (_insertedCD == "newSTCD") { + // Opening tray with Starship Titanic CD + playMovie(0, 10, 0); + playSound("a#34.wav", 50, 0, 0); + _isOpened = true; + } + } else if (_isOpened) { + if (msg->_action == "newCD1" || msg->_action == "newCD2") { + // Standard CD dropped on CDROM Tray + playMovie(33, 43, MOVIE_NOTIFY_OBJECT); + playSound("a#35.wav", 50, 0, 0); + } else if (msg->_action == "newSTCD") { + // Starship Titanic CD dropped on CDROM Tray + playMovie(11, 21, MOVIE_NOTIFY_OBJECT); + playSound("a#35.wav", 50, 0, 0); + } else { + return true; + } + + _insertedCD = msg->_action; + _isOpened = false; + } + + return true; +} + +bool CCDROMTray::MovieEndMsg(CMovieEndMsg *msg) { + CTreeItem *screen = getRoom()->findByName("newScreen"); + + if (screen) { + CActMsg actMsg(_insertedCD); + actMsg.execute(screen); + } + + return true; +} + +bool CCDROMTray::StatusChangeMsg(CStatusChangeMsg *msg) { + msg->_success = _isOpened; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/cdrom_tray.h b/engines/titanic/game/cdrom_tray.h new file mode 100644 index 0000000000..10fc1e145e --- /dev/null +++ b/engines/titanic/game/cdrom_tray.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CDROM_TRAY_H +#define TITANIC_CDROM_TRAY_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CCDROMTray : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); +public: + bool _isOpened; + CString _insertedCD; +public: + CLASSDEF; + CCDROMTray(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CDROM_TRAY_H */ diff --git a/engines/titanic/game/cell_point_button.cpp b/engines/titanic/game/cell_point_button.cpp new file mode 100644 index 0000000000..18ece09cb0 --- /dev/null +++ b/engines/titanic/game/cell_point_button.cpp @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/cell_point_button.h" + +namespace Titanic { + +CCellPointButton::CCellPointButton() : CBackground() { + _fieldE0 = 0; + _fieldE4 = 0; + _fieldE8 = 0; + _fieldEC = 0; + _fieldF0 = 0; + _fieldF4 = 0; + _fieldF8 = 0; + _fieldFC = 0; + _field100 = 0; + _field104 = 0; + _field108 = 1; +} + +void CCellPointButton::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(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_field100, indent); + file->writeNumberLine(_field104, indent); + file->writeNumberLine(_field108, indent); + file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_field118, indent); + + CBackground::save(file, indent); +} + +void CCellPointButton::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + _field100 = file->readNumber(); + _field104 = file->readNumber(); + _field108 = file->readNumber(); + _string3 = file->readString(); + _field118 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/cell_point_button.h b/engines/titanic/game/cell_point_button.h new file mode 100644 index 0000000000..6f1fdc3809 --- /dev/null +++ b/engines/titanic/game/cell_point_button.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CELL_POINT_BUTTON_H +#define TITANIC_CELL_POINT_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CCellPointButton : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; + int _fieldF4; + int _fieldF8; + int _fieldFC; + int _field100; + int _field104; + int _field108; + CString _string3; + int _field118; +public: + CLASSDEF; + CCellPointButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CELL_POINT_BUTTON_H */ diff --git a/engines/titanic/game/chev_code.cpp b/engines/titanic/game/chev_code.cpp new file mode 100644 index 0000000000..ebc20578b7 --- /dev/null +++ b/engines/titanic/game/chev_code.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/chev_code.h" + +namespace Titanic { + +void CChevCode::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CChevCode::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/chev_code.h b/engines/titanic/game/chev_code.h new file mode 100644 index 0000000000..c4552d00a2 --- /dev/null +++ b/engines/titanic/game/chev_code.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_CODE_H +#define TITANIC_CHEV_CODE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CChevCode : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CChevCode() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_CODE_H */ diff --git a/engines/titanic/game/chev_panel.cpp b/engines/titanic/game/chev_panel.cpp new file mode 100644 index 0000000000..245968e356 --- /dev/null +++ b/engines/titanic/game/chev_panel.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/chev_panel.h" + +namespace Titanic { + +void CChevPanel::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + + CGameObject::save(file, indent); +} + +void CChevPanel::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/chev_panel.h b/engines/titanic/game/chev_panel.h new file mode 100644 index 0000000000..99b5501ac2 --- /dev/null +++ b/engines/titanic/game/chev_panel.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_PANEL_H +#define TITANIC_CHEV_PANEL_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CChevPanel : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; +public: + CLASSDEF; + CChevPanel() : _fieldBC(0), _fieldC0(0), _fieldC4(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_PANEL_H */ diff --git a/engines/titanic/game/chicken_cooler.cpp b/engines/titanic/game/chicken_cooler.cpp new file mode 100644 index 0000000000..29232e10bf --- /dev/null +++ b/engines/titanic/game/chicken_cooler.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/chicken_cooler.h" + +namespace Titanic { + +void CChickenCooler::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + + CGameObject::save(file, indent); +} + +void CChickenCooler::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + + CGameObject::load(file); +} + +bool CChickenCooler::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CChickenCoolor::handlEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/chicken_cooler.h b/engines/titanic/game/chicken_cooler.h new file mode 100644 index 0000000000..724727b905 --- /dev/null +++ b/engines/titanic/game/chicken_cooler.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHICKEN_COOLER_H +#define TITANIC_CHICKEN_COOLER_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CChickenCooler : public CGameObject { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _fieldBC; + int _fieldC0; +public: + CLASSDEF; + CChickenCooler() : CGameObject(), _fieldBC(0), _fieldC0(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHICKEN_COOLER_H */ diff --git a/engines/titanic/game/chicken_dispensor.cpp b/engines/titanic/game/chicken_dispensor.cpp new file mode 100644 index 0000000000..a9bf576765 --- /dev/null +++ b/engines/titanic/game/chicken_dispensor.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/chicken_dispensor.h" + +namespace Titanic { + +CChickenDispensor::CChickenDispensor() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(0) { +} + +void CChickenDispensor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + CBackground::save(file, indent); +} + +void CChickenDispensor::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/chicken_dispensor.h b/engines/titanic/game/chicken_dispensor.h new file mode 100644 index 0000000000..d86b850871 --- /dev/null +++ b/engines/titanic/game/chicken_dispensor.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHICKEN_DISPENSOR_H +#define TITANIC_CHICKEN_DISPENSOR_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CChickenDispensor : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; +public: + CLASSDEF; + CChickenDispensor(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHICKEN_DISPENSOR_H */ diff --git a/engines/titanic/game/close_broken_pel.cpp b/engines/titanic/game/close_broken_pel.cpp new file mode 100644 index 0000000000..d27441ac96 --- /dev/null +++ b/engines/titanic/game/close_broken_pel.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/close_broken_pel.h" + +namespace Titanic { + +void CCloseBrokenPel::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string3, indent); + CBackground::save(file, indent); +} + +void CCloseBrokenPel::load(SimpleFile *file) { + file->readNumber(); + _string3 = file->readString(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/close_broken_pel.h b/engines/titanic/game/close_broken_pel.h new file mode 100644 index 0000000000..aacda6c002 --- /dev/null +++ b/engines/titanic/game/close_broken_pel.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CLOSE_BROKEN_PEL_H +#define TITANIC_CLOSE_BROKEN_PEL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CCloseBrokenPel : public CBackground { +public: + CString _string3; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CLOSE_BROKEN_PEL_H */ diff --git a/engines/titanic/game/code_wheel.cpp b/engines/titanic/game/code_wheel.cpp new file mode 100644 index 0000000000..d8ce48e390 --- /dev/null +++ b/engines/titanic/game/code_wheel.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/code_wheel.h" + +namespace Titanic { + +CodeWheel::CodeWheel() : CBomb(), _field108(0), _field10C(4), _field110(0) { +} + +void CodeWheel::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_field10C, indent); + file->writeNumberLine(_field110, indent); + + CBomb::save(file, indent); +} + +void CodeWheel::load(SimpleFile *file) { + file->readNumber(); + _field108 = file->readNumber(); + _field10C = file->readNumber(); + _field110 = file->readNumber(); + + CBomb::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/code_wheel.h b/engines/titanic/game/code_wheel.h new file mode 100644 index 0000000000..63af97c6fb --- /dev/null +++ b/engines/titanic/game/code_wheel.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CODE_WHEEL_H +#define TITANIC_CODE_WHEEL_H + +#include "titanic/game/bomb.h" + +namespace Titanic { + +class CodeWheel : public CBomb { +private: + int _field108; + int _field10C; + int _field110; +public: + CLASSDEF; + CodeWheel(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CODE_WHEEL_H */ diff --git a/engines/titanic/game/computer.cpp b/engines/titanic/game/computer.cpp new file mode 100644 index 0000000000..90574997b1 --- /dev/null +++ b/engines/titanic/game/computer.cpp @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/computer.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CComputer, CBackground) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + +void CComputer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_currentCD, indent); + file->writeNumberLine(_state, indent); + CBackground::save(file, indent); +} + +void CComputer::load(SimpleFile *file) { + file->readNumber(); + _currentCD = file->readString(); + _state = file->readNumber(); + CBackground::load(file); +} + +bool CComputer::ActMsg(CActMsg *msg) { + if (_state) { + playSound("a#35.wav", 100, 0, 0); + playMovie(32, 42, 0); + + if (msg->_action == "CD1") + playMovie(43, 49, 0); + else if (msg->_action == "CD2") + playMovie(50, 79, 0); + else if (msg->_action == "STCD") + playMovie(80, 90, 4); + + _currentCD = msg->_action; + _state = 0; + } + + return true; +} + +bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_currentCD == "None") { + if (_state) { + playSound("a#35.wav", 100, 0, 0); + playMovie(11, 21, 0); + _state = 0; + } else { + playSound("a#34.wav", 100, 0, 0); + playMovie(0, 10, 0); + _state = 1; + } + } else { + if (_state) { + loadFrame(11); + CActMsg actMsg("EjectCD"); + actMsg.execute(_currentCD); + _currentCD = "None"; + } else { + playSound("a#34.wav", 100, 0, 0); + playMovie(21, 31, 0); + _state = 1; + } + } + + return true; +} + +bool CComputer::MovieEndMsg(CMovieEndMsg *msg) { + if (msg->_endFrame == 90) { + playSound("a#32.wav", 100, 0, 0); + playSound("a#33.wav", 100, 0, 0); + playSound("a#31.wav", 100, 0, 0); + playSound("a#0.wav", 100, 0, 0); + + gotoView("Home.Node 4.E", "_TRACK,3,e-cu,4,E"); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/computer.h b/engines/titanic/game/computer.h new file mode 100644 index 0000000000..6acdba27ea --- /dev/null +++ b/engines/titanic/game/computer.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_COMPUTER_H +#define TITANIC_COMPUTER_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CComputer : public CBackground { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); +public: + CString _currentCD; + int _state; +public: + CLASSDEF; + CComputer() : CBackground(), _currentCD("None"), _state(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_COMPUTER_H */ diff --git a/engines/titanic/game/computer_screen.cpp b/engines/titanic/game/computer_screen.cpp new file mode 100644 index 0000000000..3e5172219d --- /dev/null +++ b/engines/titanic/game/computer_screen.cpp @@ -0,0 +1,140 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/computer_screen.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CComputerScreen, CGameObject) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(TimerMsg) +END_MESSAGE_MAP() + +CComputerScreen::CComputerScreen() : CGameObject() { +} + +void CComputerScreen::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CComputerScreen::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +bool CComputerScreen::ActMsg(CActMsg *msg) { + if (msg->_action == "newCD1" || msg->_action == "newCD2") { + playMovie(27, 53, MOVIE_GAMESTATE); + playMovie(19, 26, MOVIE_GAMESTATE); + } else if (msg->_action == "newSTCD") { + playMovie(0, 18, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + } + + return true; +} + +bool CComputerScreen::MovieEndMsg(CMovieEndMsg *msg) { + playSound("z#47.wav", 100, 0, 0); + addTimer(0, 3000, 0); + + for (int idx = 0; idx < 10; ++idx) + playMovie(0, 18, 0); + return true; +} + +bool CComputerScreen::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(26); + return true; +} + +bool CComputerScreen::TimerMsg(CTimerMsg *msg) { + int handle; + + switch (msg->_actionVal) { + case 0: + loadSound("a#32.wav"); + loadSound("a#31.wav"); + loadSound("a#33.wav"); + loadSound("a#30.wav"); + loadSound("a#29.wav"); + playSound("a#25.wav"); + addTimer(1, 2000, 0); + break; + + case 1: + playSound("a#32.wav"); + playSound("a#31.wav"); + addTimer(2, 2000, 0); + break; + + case 2: { + CChangeMusicMsg musicMsg(CString(), 1); + musicMsg.execute("HomeMusicPlayer"); + playSound("a#33.wav"); + playSound("a#31.wav"); + changeView("Home.Node 4.E", ""); + playClip(51, 150); + playSound("a#31.wav"); + playClip(151, 200); + + handle = playSound("a#27.wav"); + playClip(200, 306); + playSound("a#30.wav"); + stopSound(handle, 0); + + playClip(306, 338); + handle = playSound("a#28.wav"); + playClip(338, 392); + playSound("a#29.wav"); + stopSound(handle); + + playSound("y#662.wav"); + setSoundVolume(handle, 10, 2); + playClip(392, 450); + startTalking("Doorbot", 0x3611A); + sleep(8000); + + playClip(450, 492); + startTalking("Doorbot", 0x36121); + playClip(492, 522); + setSoundVolume(handle, 30, 2); + + playClip(523, 540); + setSoundVolume(handle, 0, 1); + + playClip(541, 551); + stopSound(handle); + break; + } + + default: + break; + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/computer_screen.h b/engines/titanic/game/computer_screen.h new file mode 100644 index 0000000000..8fb1dcd4dc --- /dev/null +++ b/engines/titanic/game/computer_screen.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_COMPUTER_SCREEN_H +#define TITANIC_COMPUTER_SCREEN_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CComputerScreen : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool TimerMsg(CTimerMsg *msg); +public: + CLASSDEF; + CComputerScreen(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_COMPUTER_SCREEN_H */ diff --git a/engines/titanic/game/cookie.cpp b/engines/titanic/game/cookie.cpp new file mode 100644 index 0000000000..915bb93b4a --- /dev/null +++ b/engines/titanic/game/cookie.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/cookie.h" + +namespace Titanic { + +void CCookie::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CCookie::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/cookie.h b/engines/titanic/game/cookie.h new file mode 100644 index 0000000000..7ae04f1144 --- /dev/null +++ b/engines/titanic/game/cookie.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_COOKIE_H +#define TITANIC_COOKIE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CCookie : public CGameObject { +public: + int _value1; + int _value2; +public: + CLASSDEF; + CCookie() : CGameObject(), _value1(0), _value2(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_COOKIE_H */ diff --git a/engines/titanic/game/credits.cpp b/engines/titanic/game/credits.cpp new file mode 100644 index 0000000000..7078d41a17 --- /dev/null +++ b/engines/titanic/game/credits.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/credits.h" + +namespace Titanic { + +CCredits::CCredits() : CGameObject(), _fieldBC(-1), _fieldC0(1) { +} + +void CCredits::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + + CGameObject::save(file, indent); +} + +void CCredits::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/credits.h b/engines/titanic/game/credits.h new file mode 100644 index 0000000000..fa9794b6de --- /dev/null +++ b/engines/titanic/game/credits.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CREDITS_H +#define TITANIC_CREDITS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CCredits : public CGameObject { +public: + int _fieldBC, _fieldC0; +public: + CLASSDEF; + CCredits(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CREDITS_H */ diff --git a/engines/titanic/game/credits_button.cpp b/engines/titanic/game/credits_button.cpp new file mode 100644 index 0000000000..90bb1b5ebe --- /dev/null +++ b/engines/titanic/game/credits_button.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/credits_button.h" + +namespace Titanic { + +CCreditsButton::CCreditsButton() : CBackground(), _fieldE0(1) { +} + +void CCreditsButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + CBackground::save(file, indent); +} + +void CCreditsButton::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/credits_button.h b/engines/titanic/game/credits_button.h new file mode 100644 index 0000000000..5e0bf96677 --- /dev/null +++ b/engines/titanic/game/credits_button.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CREDITS_BUTTON_H +#define TITANIC_CREDITS_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CCreditsButton : public CBackground { +public: + int _fieldE0; +public: + CLASSDEF; + CCreditsButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CREDITS_BUTTON_H */ diff --git a/engines/titanic/game/dead_area.cpp b/engines/titanic/game/dead_area.cpp new file mode 100644 index 0000000000..3c41ab34ba --- /dev/null +++ b/engines/titanic/game/dead_area.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/dead_area.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CDeadArea, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + +CDeadArea::CDeadArea() : CGameObject() { +} + +void CDeadArea::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CDeadArea::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/dead_area.h b/engines/titanic/game/dead_area.h new file mode 100644 index 0000000000..fdb44ef5df --- /dev/null +++ b/engines/titanic/game/dead_area.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DEAD_AREA_H +#define TITANIC_DEAD_AREA_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +/** + * Implements a non-responsive screen area + */ +class CDeadArea : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) { return true; } + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) { return true; } +public: + CLASSDEF; + CDeadArea(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DEAD_AREA_H */ diff --git a/engines/titanic/game/desk_click_responder.cpp b/engines/titanic/game/desk_click_responder.cpp new file mode 100644 index 0000000000..d9b2cb64b4 --- /dev/null +++ b/engines/titanic/game/desk_click_responder.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/desk_click_responder.h" + +namespace Titanic { + +void CDeskClickResponder::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldD4, indent); + file->writeNumberLine(_fieldD8, indent); + + CClickResponder::save(file, indent); +} + +void CDeskClickResponder::load(SimpleFile *file) { + file->readNumber(); + _fieldD4 = file->readNumber(); + _fieldD8 = file->readNumber(); + + CClickResponder::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/desk_click_responder.h b/engines/titanic/game/desk_click_responder.h new file mode 100644 index 0000000000..12825ba9de --- /dev/null +++ b/engines/titanic/game/desk_click_responder.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DESK_CLICK_RESPONDER_H +#define TITANIC_DESK_CLICK_RESPONDER_H + +#include "titanic/core/click_responder.h" + +namespace Titanic { + +class CDeskClickResponder : public CClickResponder { +protected: + int _fieldD4; + int _fieldD8; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DESK_CLICK_RESPONDER_H */ diff --git a/engines/titanic/game/doorbot_elevator_handler.cpp b/engines/titanic/game/doorbot_elevator_handler.cpp new file mode 100644 index 0000000000..13fc368137 --- /dev/null +++ b/engines/titanic/game/doorbot_elevator_handler.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/doorbot_elevator_handler.h" + +namespace Titanic { + +int CDoorbotElevatorHandler::_v1; + +void CDoorbotElevatorHandler::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + file->writeNumberLine(_v1, indent); + CGameObject::save(file, indent); +} + +void CDoorbotElevatorHandler::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + _v1 = file->readNumber(); + CGameObject::load(file); +} + +bool CDoorbotElevatorHandler::EnterNodeMsg(CEnterNodeMsg *msg) { + warning("CDoorbotElevatorHandler::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/doorbot_elevator_handler.h b/engines/titanic/game/doorbot_elevator_handler.h new file mode 100644 index 0000000000..7b39e727e3 --- /dev/null +++ b/engines/titanic/game/doorbot_elevator_handler.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DOORBOT_ELEVATOR_HANDLER_H +#define TITANIC_DOORBOT_ELEVATOR_HANDLER_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CDoorbotElevatorHandler : public CGameObject { + bool EnterNodeMsg(CEnterNodeMsg *msg); +private: + static int _v1; + int _value; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DOORBOT_ELEVATOR_HANDLER_H */ diff --git a/engines/titanic/game/doorbot_home_handler.cpp b/engines/titanic/game/doorbot_home_handler.cpp new file mode 100644 index 0000000000..b848308845 --- /dev/null +++ b/engines/titanic/game/doorbot_home_handler.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/doorbot_home_handler.h" + +namespace Titanic { + +CDoorbotHomeHandler::CDoorbotHomeHandler() { +} + +void CDoorbotHomeHandler::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CDoorbotHomeHandler::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/doorbot_home_handler.h b/engines/titanic/game/doorbot_home_handler.h new file mode 100644 index 0000000000..99ba6d37a9 --- /dev/null +++ b/engines/titanic/game/doorbot_home_handler.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DOORBOT_HOME_HANDLER_H +#define TITANIC_DOORBOT_HOME_HANDLER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CDoorbotHomeHandler : public CGameObject { +public: + CLASSDEF; + CDoorbotHomeHandler(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DOORBOT_HOME_HANDLER_H */ diff --git a/engines/titanic/game/ear_sweet_bowl.cpp b/engines/titanic/game/ear_sweet_bowl.cpp new file mode 100644 index 0000000000..0f7069356d --- /dev/null +++ b/engines/titanic/game/ear_sweet_bowl.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/ear_sweet_bowl.h" + +namespace Titanic { + +void CEarSweetBowl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSweetBowl::save(file, indent); +} + +void CEarSweetBowl::load(SimpleFile *file) { + file->readNumber(); + CSweetBowl::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/ear_sweet_bowl.h b/engines/titanic/game/ear_sweet_bowl.h new file mode 100644 index 0000000000..3f41950e47 --- /dev/null +++ b/engines/titanic/game/ear_sweet_bowl.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EAR_SWEET_BOWL_H +#define TITANIC_EAR_SWEET_BOWL_H + +#include "titanic/game/sweet_bowl.h" + +namespace Titanic { + +class CEarSweetBowl : public CSweetBowl { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EAR_SWEET_BOWL_H */ diff --git a/engines/titanic/game/eject_phonograph_button.cpp b/engines/titanic/game/eject_phonograph_button.cpp new file mode 100644 index 0000000000..4657f04126 --- /dev/null +++ b/engines/titanic/game/eject_phonograph_button.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/eject_phonograph_button.h" + +namespace Titanic { + +void CEjectPhonographButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeQuotedLine(_string3, indent); + file->writeQuotedLine(_string4, indent); + + CBackground::save(file, indent); +} + +void CEjectPhonographButton::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _string3 = file->readString(); + _string4 = file->readString(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/eject_phonograph_button.h b/engines/titanic/game/eject_phonograph_button.h new file mode 100644 index 0000000000..5f5da8053e --- /dev/null +++ b/engines/titanic/game/eject_phonograph_button.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EJECT_PHONOGRAPH_BUTTON_H +#define TITANIC_EJECT_PHONOGRAPH_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CEjectPhonographButton : public CBackground { +public: + int _fieldE0; + int _fieldE4; + CString _string3; + CString _string4; +public: + CLASSDEF; + CEjectPhonographButton() : CBackground(), _fieldE0(0), _fieldE4(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EJECT_PHONOGRAPH_BUTTON_H */ diff --git a/engines/titanic/game/elevator_action_area.cpp b/engines/titanic/game/elevator_action_area.cpp new file mode 100644 index 0000000000..1cbff8d64d --- /dev/null +++ b/engines/titanic/game/elevator_action_area.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/elevator_action_area.h" + +namespace Titanic { + +void CElevatorActionArea::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CElevatorActionArea::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/elevator_action_area.h b/engines/titanic/game/elevator_action_area.h new file mode 100644 index 0000000000..6c756fb95f --- /dev/null +++ b/engines/titanic/game/elevator_action_area.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ELEVATOR_ACTION_AREA_H +#define TITANIC_ELEVATOR_ACTION_AREA_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CElevatorActionArea : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CElevatorActionArea() : CGameObject(), _value(4) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ELEVATOR_ACTION_AREA_H */ diff --git a/engines/titanic/game/emma_control.cpp b/engines/titanic/game/emma_control.cpp new file mode 100644 index 0000000000..814cb44d79 --- /dev/null +++ b/engines/titanic/game/emma_control.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/emma_control.h" + +namespace Titanic { + +int CEmmaControl::_v1; + +void CEmmaControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeQuotedLine(_wavFile1, indent); + file->writeQuotedLine(_wavFile2, indent); + + CBackground::save(file, indent); +} + +void CEmmaControl::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _wavFile1 = file->readString(); + _wavFile2 = file->readString(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/emma_control.h b/engines/titanic/game/emma_control.h new file mode 100644 index 0000000000..721660f61e --- /dev/null +++ b/engines/titanic/game/emma_control.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EMMA_CONTROL_H +#define TITANIC_EMMA_CONTROL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CEmmaControl : public CBackground { +private: + static int _v1; + + CString _wavFile1, _wavFile2; +public: + CLASSDEF; + CEmmaControl() : CBackground(), _wavFile1("b#39.wav"), _wavFile2("b#38.wav") {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EMMA_CONTROL_H */ diff --git a/engines/titanic/game/empty_nut_bowl.cpp b/engines/titanic/game/empty_nut_bowl.cpp new file mode 100644 index 0000000000..ae9cb35e4d --- /dev/null +++ b/engines/titanic/game/empty_nut_bowl.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/empty_nut_bowl.h" + +namespace Titanic { + +void CEmptyNutBowl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CEmptyNutBowl::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/empty_nut_bowl.h b/engines/titanic/game/empty_nut_bowl.h new file mode 100644 index 0000000000..112e2c6075 --- /dev/null +++ b/engines/titanic/game/empty_nut_bowl.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EMPTY_NUT_BOWL_H +#define TITANIC_EMPTY_NUT_BOWL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CEmptyNutBowl : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CEmptyNutBowl() : CGameObject(), _value(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EMPTY_NUT_BOWL_H */ diff --git a/engines/titanic/game/end_credit_text.cpp b/engines/titanic/game/end_credit_text.cpp new file mode 100644 index 0000000000..6e0c21bbe9 --- /dev/null +++ b/engines/titanic/game/end_credit_text.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/end_credit_text.h" + +namespace Titanic { + +void CEndCreditText::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CEndCreditText::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/end_credit_text.h b/engines/titanic/game/end_credit_text.h new file mode 100644 index 0000000000..54c6c7ff73 --- /dev/null +++ b/engines/titanic/game/end_credit_text.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_END_CREDIT_TEXT_H +#define TITANIC_END_CREDIT_TEXT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CEndCreditText : public CGameObject { +private: + int _value; +public: + CLASSDEF; + CEndCreditText() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_END_CREDIT_TEXT_H */ diff --git a/engines/titanic/game/end_credits.cpp b/engines/titanic/game/end_credits.cpp new file mode 100644 index 0000000000..61640b92ad --- /dev/null +++ b/engines/titanic/game/end_credits.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/end_credits.h" + +namespace Titanic { + +void CEndCredits::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CEndCredits::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/end_credits.h b/engines/titanic/game/end_credits.h new file mode 100644 index 0000000000..d160bc94e8 --- /dev/null +++ b/engines/titanic/game/end_credits.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_END_CREDITS_H +#define TITANIC_END_CREDITS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CEndCredits : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CEndCredits() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_END_CREDITS_H */ diff --git a/engines/titanic/game/end_explode_ship.cpp b/engines/titanic/game/end_explode_ship.cpp new file mode 100644 index 0000000000..f7ac36503f --- /dev/null +++ b/engines/titanic/game/end_explode_ship.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/end_explode_ship.h" + +namespace Titanic { + +void CEndExplodeShip::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CEndExplodeShip::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/end_explode_ship.h b/engines/titanic/game/end_explode_ship.h new file mode 100644 index 0000000000..b8159d3ca7 --- /dev/null +++ b/engines/titanic/game/end_explode_ship.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_END_EXPLODE_SHIP_H +#define TITANIC_END_EXPLODE_SHIP_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CEndExplodeShip : public CGameObject { +public: + int _value1, _value2; +public: + CLASSDEF; + CEndExplodeShip() : CGameObject(), _value1(0), _value2(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_END_EXPLODE_SHIP_H */ diff --git a/engines/titanic/game/end_game_credits.cpp b/engines/titanic/game/end_game_credits.cpp new file mode 100644 index 0000000000..2d1aa79b1d --- /dev/null +++ b/engines/titanic/game/end_game_credits.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/end_game_credits.h" + +namespace Titanic { + +CEndGameCredits::CEndGameCredits() : CGameObject(), _fieldBC(0) { +} + +void CEndGameCredits::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writePoint(_pos1, indent); + + CGameObject::save(file, indent); +} + +void CEndGameCredits::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _pos1 = file->readPoint(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/end_game_credits.h b/engines/titanic/game/end_game_credits.h new file mode 100644 index 0000000000..5962950737 --- /dev/null +++ b/engines/titanic/game/end_game_credits.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_END_GAME_CREDITS_H +#define TITANIC_END_GAME_CREDITS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CEndGameCredits : public CGameObject { +private: + int _fieldBC; + Point _pos1; +public: + CLASSDEF; + CEndGameCredits(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_END_GAME_CREDITS_H */ diff --git a/engines/titanic/game/end_sequence_control.cpp b/engines/titanic/game/end_sequence_control.cpp new file mode 100644 index 0000000000..d32b3d1713 --- /dev/null +++ b/engines/titanic/game/end_sequence_control.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/end_sequence_control.h" + +namespace Titanic { + +void CEndSequenceControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CEndSequenceControl::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +bool CEndSequenceControl::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("TODO: CEndSequenceControl::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/end_sequence_control.h b/engines/titanic/game/end_sequence_control.h new file mode 100644 index 0000000000..35e9a934e1 --- /dev/null +++ b/engines/titanic/game/end_sequence_control.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_END_SEQUENCE_CONTROL_H +#define TITANIC_END_SEQUENCE_CONTROL_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CEndSequenceControl : public CGameObject { + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_END_SEQUENCE_CONTROL_H */ diff --git a/engines/titanic/game/fan.cpp b/engines/titanic/game/fan.cpp new file mode 100644 index 0000000000..eabaf63568 --- /dev/null +++ b/engines/titanic/game/fan.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/fan.h" + +namespace Titanic { + +void CFan::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CFan::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/fan.h b/engines/titanic/game/fan.h new file mode 100644 index 0000000000..2c5a2410a8 --- /dev/null +++ b/engines/titanic/game/fan.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FAN_H +#define TITANIC_FAN_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CFan : public CGameObject { +public: + int _value1, _value2; +public: + CLASSDEF; + CFan() : CGameObject(), _value1(0), _value2(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FAN_H */ diff --git a/engines/titanic/game/fan_control.cpp b/engines/titanic/game/fan_control.cpp new file mode 100644 index 0000000000..a42e4dd5c1 --- /dev/null +++ b/engines/titanic/game/fan_control.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/fan_control.h" + +namespace Titanic { + +CFanControl::CFanControl() : CGameObject(), _fieldBC(0), + _fieldC0(0), _fieldC4(0), _fieldC8(0), _fieldCC(0) { +} + +void CFanControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + + CGameObject::save(file, indent); +} + +void CFanControl::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/fan_control.h b/engines/titanic/game/fan_control.h new file mode 100644 index 0000000000..4d89adb311 --- /dev/null +++ b/engines/titanic/game/fan_control.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FAN_CONTROL_H +#define TITANIC_FAN_CONTROL_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CFanControl : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; +public: + CLASSDEF; + CFanControl(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FAN_CONTROL_H */ diff --git a/engines/titanic/game/fan_decrease.cpp b/engines/titanic/game/fan_decrease.cpp new file mode 100644 index 0000000000..2049b1ebc9 --- /dev/null +++ b/engines/titanic/game/fan_decrease.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/fan_decrease.h" + +namespace Titanic { + +void CFanDecrease::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CFanDecrease::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/fan_decrease.h b/engines/titanic/game/fan_decrease.h new file mode 100644 index 0000000000..765c7d1560 --- /dev/null +++ b/engines/titanic/game/fan_decrease.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FAN_DECREASE_H +#define TITANIC_FAN_DECREASE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CFanDecrease : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FAN_DECREASE_H */ diff --git a/engines/titanic/game/fan_increase.cpp b/engines/titanic/game/fan_increase.cpp new file mode 100644 index 0000000000..aa23dd9275 --- /dev/null +++ b/engines/titanic/game/fan_increase.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/fan_increase.h" + +namespace Titanic { + +void CFanIncrease::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CFanIncrease::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/fan_increase.h b/engines/titanic/game/fan_increase.h new file mode 100644 index 0000000000..08ec1322cd --- /dev/null +++ b/engines/titanic/game/fan_increase.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FAN_INCREASE_H +#define TITANIC_FAN_INCREASE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CFanIncrease : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FAN_INCREASE_H */ diff --git a/engines/titanic/game/fan_noises.cpp b/engines/titanic/game/fan_noises.cpp new file mode 100644 index 0000000000..14177ab64e --- /dev/null +++ b/engines/titanic/game/fan_noises.cpp @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/fan_noises.h" + +namespace Titanic { + +CFanNoises::CFanNoises() : CGameObject(), _fieldBC(-1), + _fieldC0(0), _fieldC4(70), _fieldC8(-1), _fieldCC(0), + _fieldD0(0), _fieldD4(-1) { +} + +void CFanNoises::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeNumberLine(_fieldD0, indent); + file->writeNumberLine(_fieldD4, indent); + + CGameObject::save(file, indent); +} + +void CFanNoises::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + _fieldD0 = file->readNumber(); + _fieldD4 = file->readNumber(); + + CGameObject::load(file); +} + +bool CFanNoises::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CFanNoises::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/fan_noises.h b/engines/titanic/game/fan_noises.h new file mode 100644 index 0000000000..bb2c35989d --- /dev/null +++ b/engines/titanic/game/fan_noises.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FAN_NOISES_H +#define TITANIC_FAN_NOISES_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CFanNoises : public CGameObject { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; + int _fieldD0; + int _fieldD4; +public: + CLASSDEF; + CFanNoises(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FAN_NOISES_H */ diff --git a/engines/titanic/game/floor_indicator.cpp b/engines/titanic/game/floor_indicator.cpp new file mode 100644 index 0000000000..360232c38c --- /dev/null +++ b/engines/titanic/game/floor_indicator.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/floor_indicator.h" + +namespace Titanic { + +void CFloorIndicator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CFloorIndicator::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/floor_indicator.h b/engines/titanic/game/floor_indicator.h new file mode 100644 index 0000000000..066209e52e --- /dev/null +++ b/engines/titanic/game/floor_indicator.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FLOOR_INDICATOR_H +#define TITANIC_FLOOR_INDICATOR_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CFloorIndicator : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FLOOR_INDICATOR_H */ diff --git a/engines/titanic/game/games_console.cpp b/engines/titanic/game/games_console.cpp new file mode 100644 index 0000000000..b7500f9dd9 --- /dev/null +++ b/engines/titanic/game/games_console.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/games_console.h" + +namespace Titanic { + +void CGamesConsole::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + CBackground::save(file, indent); +} + +void CGamesConsole::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/games_console.h b/engines/titanic/game/games_console.h new file mode 100644 index 0000000000..2b1da70e96 --- /dev/null +++ b/engines/titanic/game/games_console.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GAMES_CONSOLE_H +#define TITANIC_GAMES_CONSOLE_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CGamesConsole : public CBackground { +public: + int _fieldE0; +public: + CLASSDEF; + CGamesConsole() : CBackground(), _fieldE0(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GAMES_CONSOLE_H */ diff --git a/engines/titanic/game/get_lift_eye2.cpp b/engines/titanic/game/get_lift_eye2.cpp new file mode 100644 index 0000000000..7747f7b0c2 --- /dev/null +++ b/engines/titanic/game/get_lift_eye2.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/get_lift_eye2.h" + +namespace Titanic { + +CString *CGetLiftEye2::_v1; + +void CGetLiftEye2::init() { + _v1 = new CString(); +} + +void CGetLiftEye2::deinit() { + delete _v1; +} + +void CGetLiftEye2::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(*_v1, indent); + CGameObject::save(file, indent); +} + +void CGetLiftEye2::load(SimpleFile *file) { + file->readNumber(); + *_v1 = file->readString(); + CGameObject::load(file); +} + +bool CGetLiftEye2::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CGetLiftEye2::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/get_lift_eye2.h b/engines/titanic/game/get_lift_eye2.h new file mode 100644 index 0000000000..496784a3c1 --- /dev/null +++ b/engines/titanic/game/get_lift_eye2.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GET_LIFT_EYE2_H +#define TITANIC_GET_LIFT_EYE2_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" +namespace Titanic { + +class CGetLiftEye2 : public CGameObject { + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + static CString *_v1; +public: + CLASSDEF; + static void init(); + static void deinit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GET_LIFT_EYE2_H */ diff --git a/engines/titanic/game/glass_smasher.cpp b/engines/titanic/game/glass_smasher.cpp new file mode 100644 index 0000000000..8c33124a47 --- /dev/null +++ b/engines/titanic/game/glass_smasher.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/glass_smasher.h" + +namespace Titanic { + +void CGlassSmasher::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CGlassSmasher::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/glass_smasher.h b/engines/titanic/game/glass_smasher.h new file mode 100644 index 0000000000..7e38f4e36b --- /dev/null +++ b/engines/titanic/game/glass_smasher.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GLASS_SMASHER_H +#define TITANIC_GLASS_SMASHER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CGlassSmasher : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GLASS_SMASHER_H */ diff --git a/engines/titanic/game/gondolier/gondolier_base.cpp b/engines/titanic/game/gondolier/gondolier_base.cpp new file mode 100644 index 0000000000..1f7339cf38 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_base.cpp @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/gondolier/gondolier_base.h" + +namespace Titanic { + +int CGondolierBase::_v1; +int CGondolierBase::_v2; +int CGondolierBase::_v3; +int CGondolierBase::_v4; +int CGondolierBase::_v5; +int CGondolierBase::_v6; +int CGondolierBase::_v7; +int CGondolierBase::_v8; +int CGondolierBase::_v9; +int CGondolierBase::_v10; + +void CGondolierBase::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_v3, indent); + file->writeNumberLine(_v4, indent); + file->writeNumberLine(_v5, indent); + file->writeNumberLine(_v6, indent); + file->writeNumberLine(_v7, indent); + file->writeNumberLine(_v8, indent); + file->writeNumberLine(_v9, indent); + file->writeNumberLine(_v10, indent); + + CGameObject::save(file, indent); +} + +void CGondolierBase::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _v3 = file->readNumber(); + _v4 = file->readNumber(); + _v5 = file->readNumber(); + _v6 = file->readNumber(); + _v7 = file->readNumber(); + _v8 = file->readNumber(); + _v9 = file->readNumber(); + _v10 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/gondolier/gondolier_base.h b/engines/titanic/game/gondolier/gondolier_base.h new file mode 100644 index 0000000000..a7ea2d4931 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_base.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GONDOLIER_BASE_H +#define TITANIC_GONDOLIER_BASE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CGondolierBase : public CGameObject { +private: + static int _v1; + static int _v2; + static int _v3; + static int _v4; + static int _v5; + static int _v6; + static int _v7; + static int _v8; + static int _v9; + static int _v10; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GONDOLIER_BASE_H */ diff --git a/engines/titanic/game/gondolier/gondolier_chest.cpp b/engines/titanic/game/gondolier/gondolier_chest.cpp new file mode 100644 index 0000000000..b3e7217502 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_chest.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/gondolier/gondolier_chest.h" + +namespace Titanic { + +void CGondolierChest::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGondolierBase::save(file, indent); +} + +void CGondolierChest::load(SimpleFile *file) { + file->readNumber(); + CGondolierBase::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/gondolier/gondolier_chest.h b/engines/titanic/game/gondolier/gondolier_chest.h new file mode 100644 index 0000000000..d796917371 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_chest.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GONDOLIER_CHEST_H +#define TITANIC_GONDOLIER_CHEST_H + +#include "titanic/game/gondolier/gondolier_base.h" + +namespace Titanic { + +class CGondolierChest : public CGondolierBase { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GONDOLIER_CHEST_H */ diff --git a/engines/titanic/game/gondolier/gondolier_face.cpp b/engines/titanic/game/gondolier/gondolier_face.cpp new file mode 100644 index 0000000000..bdab8491ed --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_face.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/gondolier/gondolier_face.h" + +namespace Titanic { + +void CGondolierFace::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + CGondolierBase::save(file, indent); +} + +void CGondolierFace::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + CGondolierBase::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/gondolier/gondolier_face.h b/engines/titanic/game/gondolier/gondolier_face.h new file mode 100644 index 0000000000..71bdd6d444 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_face.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GONDOLIER_FACE_H +#define TITANIC_GONDOLIER_FACE_H + +#include "titanic/game/gondolier/gondolier_base.h" + +namespace Titanic { + +class CGondolierFace : public CGondolierBase { +private: + int _fieldBC; +public: + CLASSDEF; + CGondolierFace() : CGondolierBase(), _fieldBC(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GONDOLIER_FACE_H */ diff --git a/engines/titanic/game/gondolier/gondolier_mixer.cpp b/engines/titanic/game/gondolier/gondolier_mixer.cpp new file mode 100644 index 0000000000..9b7b72c11b --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_mixer.cpp @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/gondolier/gondolier_mixer.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +CGondolierMixer::CGondolierMixer() : CGondolierBase(), + _string1("c#0.wav"), _string2("c#1.wav"), + _fieldBC(-1), _fieldC0(-1), _fieldC4(0), _fieldC8(0), + _fieldE4(0) { +} + +void CGondolierMixer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_fieldE4, indent); + + CGondolierBase::save(file, indent); +} + +void CGondolierMixer::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + _fieldE4 = file->readNumber(); + + CGondolierBase::load(file); +} + +bool CGondolierMixer::EnterRoomMsg(CEnterRoomMsg *msg) { + CRoomItem *parentRoom = dynamic_cast<CRoomItem *>(getParent()); + if (parentRoom == msg->_newRoom) + msg->execute(parentRoom); + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/gondolier/gondolier_mixer.h b/engines/titanic/game/gondolier/gondolier_mixer.h new file mode 100644 index 0000000000..247e520ba6 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_mixer.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GONDOLIER_MIXER_H +#define TITANIC_GONDOLIER_MIXER_H + +#include "titanic/game/gondolier/gondolier_base.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CGondolierMixer : public CGondolierBase { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + CString _string1; + CString _string2; + int _fieldE4; +public: + CLASSDEF; + CGondolierMixer(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GONDOLIER_MIXER_H */ diff --git a/engines/titanic/game/gondolier/gondolier_slider.cpp b/engines/titanic/game/gondolier/gondolier_slider.cpp new file mode 100644 index 0000000000..eb6b1a9ad8 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_slider.cpp @@ -0,0 +1,82 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/gondolier/gondolier_slider.h" + +namespace Titanic { + +CGondolierSlider::CGondolierSlider() : CGondolierBase(), + _fieldBC(0), _fieldC0(0), _fieldC4(0), _fieldC8(0), + _fieldCC(0), _fieldD0(0), _fieldD4(0), _fieldD8(0), + _fieldDC(0), _fieldE0(0), _fieldE4(0), _fieldE8(0), + _fieldEC(0), _string1("NULL"), _fieldFC(0), _field118(0) { +} + +void CGondolierSlider::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeNumberLine(_fieldD0, indent); + file->writeNumberLine(_fieldD4, indent); + file->writeNumberLine(_fieldD8, indent); + file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_fieldFC, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_field118, indent); + + CGondolierBase::save(file, indent); +} + +void CGondolierSlider::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + _fieldD0 = file->readNumber(); + _fieldD4 = file->readNumber(); + _fieldD8 = file->readNumber(); + _fieldDC = file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _string1 = file->readString(); + _fieldFC = file->readNumber(); + _string2 = file->readString(); + _string3 = file->readString(); + _field118 = file->readNumber(); + + CGondolierBase::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/gondolier/gondolier_slider.h b/engines/titanic/game/gondolier/gondolier_slider.h new file mode 100644 index 0000000000..0ae14a91a0 --- /dev/null +++ b/engines/titanic/game/gondolier/gondolier_slider.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GONDOLIER_SLIDER_H +#define TITANIC_GONDOLIER_SLIDER_H + +#include "titanic/game/gondolier/gondolier_base.h" + +namespace Titanic { + +class CGondolierSlider : public CGondolierBase { +private: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; + int _fieldD0; + int _fieldD4; + int _fieldD8; + int _fieldDC; + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + CString _string1; + int _fieldFC; + CString _string2; + CString _string3; + int _field118; +public: + CLASSDEF; + CGondolierSlider(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GONDOLIER_SLIDER_H */ diff --git a/engines/titanic/game/hammer_clip.cpp b/engines/titanic/game/hammer_clip.cpp new file mode 100644 index 0000000000..e3f3a09a90 --- /dev/null +++ b/engines/titanic/game/hammer_clip.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/hammer_clip.h" + +namespace Titanic { + +void CHammerClip::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CHammerClip::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/hammer_clip.h b/engines/titanic/game/hammer_clip.h new file mode 100644 index 0000000000..7f5c5ab5f8 --- /dev/null +++ b/engines/titanic/game/hammer_clip.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HAMMER_CLIP_H +#define TITANIC_HAMMER_CLIP_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CHammerClip : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CHammerClip() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HAMMER_CLIP_H */ diff --git a/engines/titanic/game/hammer_dispensor.cpp b/engines/titanic/game/hammer_dispensor.cpp new file mode 100644 index 0000000000..440fe1bc7b --- /dev/null +++ b/engines/titanic/game/hammer_dispensor.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/hammer_dispensor.h" + +namespace Titanic { + +CHammerDispensor::CHammerDispensor() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(0) { +} + +void CHammerDispensor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + + CBackground::save(file, indent); +} + +void CHammerDispensor::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/hammer_dispensor.h b/engines/titanic/game/hammer_dispensor.h new file mode 100644 index 0000000000..e1b30d9045 --- /dev/null +++ b/engines/titanic/game/hammer_dispensor.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HAMMER_DISPENSOR_H +#define TITANIC_HAMMER_DISPENSOR_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CHammerDispensor : public CBackground { +private: + int _fieldE0; + int _fieldE4; + int _fieldE8; +public: + CLASSDEF; + CHammerDispensor(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HAMMER_DISPENSOR_H */ diff --git a/engines/titanic/game/hammer_dispensor_button.cpp b/engines/titanic/game/hammer_dispensor_button.cpp new file mode 100644 index 0000000000..3346498623 --- /dev/null +++ b/engines/titanic/game/hammer_dispensor_button.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/hammer_dispensor_button.h" + +namespace Titanic { + +CHammerDispensorButton::CHammerDispensorButton() : CStartAction(), + _fieldF8(0), _fieldFC(0), _field100(0), _field104(56), + _field108(6), _field10C(0), _field110(0) { +} + +void CHammerDispensorButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_field100, indent); + file->writeNumberLine(_field104, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_field110, indent); + + CStartAction::save(file, indent); +} + +void CHammerDispensorButton::load(SimpleFile *file) { + file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + _field100 = file->readNumber(); + _field104 = file->readNumber(); + _field108 = file->readNumber(); + _field110 = file->readNumber(); + + CStartAction::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/hammer_dispensor_button.h b/engines/titanic/game/hammer_dispensor_button.h new file mode 100644 index 0000000000..36732adb2d --- /dev/null +++ b/engines/titanic/game/hammer_dispensor_button.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HAMMER_DISPENSOR_BUTTON_H +#define TITANIC_HAMMER_DISPENSOR_BUTTON_H + +#include "titanic/game/start_action.h" + +namespace Titanic { + +class CHammerDispensorButton : public CStartAction { +private: + int _fieldF8; + int _fieldFC; + int _field100; + int _field104; + int _field108; + int _field10C; + int _field110; +public: + CLASSDEF; + CHammerDispensorButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HAMMER_DISPENSOR_BUTTON_H */ diff --git a/engines/titanic/game/head_slot.cpp b/engines/titanic/game/head_slot.cpp new file mode 100644 index 0000000000..32650b75e4 --- /dev/null +++ b/engines/titanic/game/head_slot.cpp @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/head_slot.h" + +namespace Titanic { + +int CHeadSlot::_v1; + +CHeadSlot::CHeadSlot() : CGameObject(), _string1("NotWorking"), _string2("NULL"), + _fieldBC(0), _fieldD8(0), _fieldDC(27), _fieldE0(56), + _fieldE4(82), _fieldE8(112), _fieldEC(0) { +} + +void CHeadSlot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_fieldD8, indent); + file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_fieldEC, indent); + + CGameObject::save(file, indent); +} + +void CHeadSlot::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + _fieldD8 = file->readNumber(); + _fieldDC = file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _v1 = file->readNumber(); + _fieldEC = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/head_slot.h b/engines/titanic/game/head_slot.h new file mode 100644 index 0000000000..0080411033 --- /dev/null +++ b/engines/titanic/game/head_slot.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HEAD_SLOT_H +#define TITANIC_HEAD_SLOT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CHeadSlot : public CGameObject { +public: + static int _v1; +public: + int _fieldBC; + CString _string1; + CString _string2; + int _fieldD8; + int _fieldDC; + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; +public: + CLASSDEF; + CHeadSlot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HEAD_SLOT_H */ diff --git a/engines/titanic/game/head_smash_event.cpp b/engines/titanic/game/head_smash_event.cpp new file mode 100644 index 0000000000..5b79acf7a5 --- /dev/null +++ b/engines/titanic/game/head_smash_event.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/head_smash_event.h" + +namespace Titanic { + +void CHeadSmashEvent::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBackground::save(file, indent); +} + +void CHeadSmashEvent::load(SimpleFile *file) { + file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/head_smash_event.h b/engines/titanic/game/head_smash_event.h new file mode 100644 index 0000000000..912cf36bf3 --- /dev/null +++ b/engines/titanic/game/head_smash_event.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HEAD_SMASH_EVENT_H +#define TITANIC_HEAD_SMASH_EVENT_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CHeadSmashEvent : public CBackground { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HEAD_SMASH_EVENT_H */ diff --git a/engines/titanic/game/head_smash_lever.cpp b/engines/titanic/game/head_smash_lever.cpp new file mode 100644 index 0000000000..5a2fe1f4c2 --- /dev/null +++ b/engines/titanic/game/head_smash_lever.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/head_smash_lever.h" + +namespace Titanic { + +CHeadSmashLever::CHeadSmashLever() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(0) {} + +void CHeadSmashLever::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + + CBackground::save(file, indent); +} + +void CHeadSmashLever::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/head_smash_lever.h b/engines/titanic/game/head_smash_lever.h new file mode 100644 index 0000000000..b8f04d39de --- /dev/null +++ b/engines/titanic/game/head_smash_lever.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HEAD_SMASH_LEVER_H +#define TITANIC_HEAD_SMASH_LEVER_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CHeadSmashLever : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; +public: + CLASSDEF; + CHeadSmashLever(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HEAD_SMASH_LEVER_H */ diff --git a/engines/titanic/game/head_spinner.cpp b/engines/titanic/game/head_spinner.cpp new file mode 100644 index 0000000000..2fb3654c4a --- /dev/null +++ b/engines/titanic/game/head_spinner.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/head_spinner.h" + +namespace Titanic { + +void CHeadSpinner::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CHeadSpinner::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/head_spinner.h b/engines/titanic/game/head_spinner.h new file mode 100644 index 0000000000..4456070ee4 --- /dev/null +++ b/engines/titanic/game/head_spinner.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HEAD_SPINNER_H +#define TITANIC_HEAD_SPINNER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CHeadSpinner : public CGameObject { +public: + int _value1, _value2; +public: + CHeadSpinner() : CGameObject(), _value1(0), _value2(0) {} + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HEAD_SPINNER_H */ diff --git a/engines/titanic/game/idle_summoner.cpp b/engines/titanic/game/idle_summoner.cpp new file mode 100644 index 0000000000..19d760a8db --- /dev/null +++ b/engines/titanic/game/idle_summoner.cpp @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/idle_summoner.h" + +namespace Titanic { + +CIdleSummoner::CIdleSummoner() : CGameObject(), _fieldBC(0x57E40), + _fieldC0(0xEA60), _fieldC4(0x57E40), _fieldC8(0xEA60), + _fieldCC(0xEA60), _fieldD0(0xEA60), _fieldD4(0xEA60), + _fieldD8(0xEA60), _fieldDC(0xEA60) { +} + +void CIdleSummoner::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeNumberLine(_fieldD0, indent); + file->writeNumberLine(_fieldD4, indent); + file->writeNumberLine(_fieldD8, indent); + file->writeNumberLine(_fieldDC, indent); + + CGameObject::save(file, indent); +} + +void CIdleSummoner::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + _fieldD0 = file->readNumber(); + _fieldD4 = file->readNumber(); + _fieldD8 = file->readNumber(); + _fieldDC = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/idle_summoner.h b/engines/titanic/game/idle_summoner.h new file mode 100644 index 0000000000..1d9fcdd176 --- /dev/null +++ b/engines/titanic/game/idle_summoner.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_IDLE_SUMMONER_H +#define TITANIC_IDLE_SUMMONER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CIdleSummoner : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; + int _fieldD0; + int _fieldD4; + int _fieldD8; + int _fieldDC; +public: + CIdleSummoner(); + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_IDLE_SUMMONER_H */ diff --git a/engines/titanic/game/leave_sec_class_state.cpp b/engines/titanic/game/leave_sec_class_state.cpp new file mode 100644 index 0000000000..3e23e3ad1c --- /dev/null +++ b/engines/titanic/game/leave_sec_class_state.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/leave_sec_class_state.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CLeaveSecClassState, CGameObject); + +void CLeaveSecClassState::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CLeaveSecClassState::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/leave_sec_class_state.h b/engines/titanic/game/leave_sec_class_state.h new file mode 100644 index 0000000000..0b1e854f57 --- /dev/null +++ b/engines/titanic/game/leave_sec_class_state.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LEAVE_SEC_CLASS_STATE_H +#define TITANIC_LEAVE_SEC_CLASS_STATE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CLeaveSecClassState : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LEAVE_SEC_CLASS_STATE_H */ diff --git a/engines/titanic/game/lemon_dispensor.cpp b/engines/titanic/game/lemon_dispensor.cpp new file mode 100644 index 0000000000..8e1674cb2d --- /dev/null +++ b/engines/titanic/game/lemon_dispensor.cpp @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/lemon_dispensor.h" + +namespace Titanic { + +int CLemonDispensor::_v1; +int CLemonDispensor::_v2; +int CLemonDispensor::_v3; + +CLemonDispensor::CLemonDispensor() : CBackground(), + _fieldE0(0), _fieldE4(9), _fieldE8(15), _fieldEC(0) { +} + +void CLemonDispensor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_v3, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_fieldEC, indent); + + CBackground::save(file, indent); +} + +void CLemonDispensor::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _v3 = file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/lemon_dispensor.h b/engines/titanic/game/lemon_dispensor.h new file mode 100644 index 0000000000..d6315ed620 --- /dev/null +++ b/engines/titanic/game/lemon_dispensor.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LEMON_DISPENSOR_H +#define TITANIC_LEMON_DISPENSOR_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CLemonDispensor : public CBackground { +private: + static int _v1; + static int _v2; + static int _v3; + + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; +public: + CLASSDEF; + CLemonDispensor(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LEMON_DISPENSOR_H */ diff --git a/engines/titanic/game/light.cpp b/engines/titanic/game/light.cpp new file mode 100644 index 0000000000..fd3c446875 --- /dev/null +++ b/engines/titanic/game/light.cpp @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/light.h" + +namespace Titanic { + +CLight::CLight() : CBackground(), _fieldE0(0), _fieldE4(0), + _fieldE8(0), _fieldEC(0), _fieldF0(0), _fieldF4(0), + _fieldF8(0), _fieldFC(0) { +} + +void CLight::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(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + + CBackground::save(file, indent); +} + +void CLight::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + + CBackground::load(file); +} + +bool CLight::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CLight::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/light.h b/engines/titanic/game/light.h new file mode 100644 index 0000000000..79e4bc400e --- /dev/null +++ b/engines/titanic/game/light.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LIGHT_H +#define TITANIC_LIGHT_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CLight : public CBackground { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; + int _fieldF4; + int _fieldF8; + int _fieldFC; +public: + CLASSDEF; + CLight(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIGHT_H */ diff --git a/engines/titanic/game/light_switch.cpp b/engines/titanic/game/light_switch.cpp new file mode 100644 index 0000000000..3f5c8d2084 --- /dev/null +++ b/engines/titanic/game/light_switch.cpp @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/light_switch.h" + +namespace Titanic { + +int CLightSwitch::_v1; + +CLightSwitch::CLightSwitch() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(0) { +} + +void CLightSwitch::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_fieldE8, indent); + + CBackground::save(file, indent); +} + +void CLightSwitch::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _v1 = file->readNumber(); + _fieldE8 = file->readNumber(); + + CBackground::load(file); +} + +bool CLightSwitch::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CLightSwitch::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/light_switch.h b/engines/titanic/game/light_switch.h new file mode 100644 index 0000000000..ce62d7d68c --- /dev/null +++ b/engines/titanic/game/light_switch.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LIGHT_SWITCH_H +#define TITANIC_LIGHT_SWITCH_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CLightSwitch : public CBackground { + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + static int _v1; +private: + int _fieldE0; + int _fieldE4; + int _fieldE8; +public: + CLASSDEF; + CLightSwitch(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIGHT_SWITCH_H */ diff --git a/engines/titanic/game/little_lift_button.cpp b/engines/titanic/game/little_lift_button.cpp new file mode 100644 index 0000000000..5005cb1757 --- /dev/null +++ b/engines/titanic/game/little_lift_button.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/little_lift_button.h" + +namespace Titanic { + +void CLittleLiftButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CBackground::save(file, indent); +} + +void CLittleLiftButton::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/little_lift_button.h b/engines/titanic/game/little_lift_button.h new file mode 100644 index 0000000000..b14651f4b8 --- /dev/null +++ b/engines/titanic/game/little_lift_button.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LITTLE_LIFT_BUTTON_H +#define TITANIC_LITTLE_LIFT_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CLittleLiftButton : public CBackground { +private: + int _value; +public: + CLASSDEF; + CLittleLiftButton() : CBackground(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LITTLE_LIFT_BUTTON_H */ diff --git a/engines/titanic/game/long_stick_dispenser.cpp b/engines/titanic/game/long_stick_dispenser.cpp new file mode 100644 index 0000000000..cb562ec3ca --- /dev/null +++ b/engines/titanic/game/long_stick_dispenser.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/long_stick_dispenser.h" + +namespace Titanic { + +void CLongStickDispenser::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + + CGameObject::save(file, indent); +} + +void CLongStickDispenser::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + + CGameObject::load(file); +} + +bool CLongStickDispenser::EnterRoomMsg(CEnterRoomMsg *msg) { + _fieldC0 = 0; + _fieldC4 = 1; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/long_stick_dispenser.h b/engines/titanic/game/long_stick_dispenser.h new file mode 100644 index 0000000000..2a1b86fb84 --- /dev/null +++ b/engines/titanic/game/long_stick_dispenser.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LONG_STICK_DISPENSER_H +#define TITANIC_LONG_STICK_DISPENSER_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CLongStickDispenser : public CGameObject { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _fieldBC; + int _fieldC0; + int _fieldC4; +public: + CLASSDEF; + CLongStickDispenser() : CGameObject(), _fieldBC(0), + _fieldC0(0), _fieldC4(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LONG_STICK_DISPENSER_H */ diff --git a/engines/titanic/game/maitred/maitred_arm_holder.cpp b/engines/titanic/game/maitred/maitred_arm_holder.cpp new file mode 100644 index 0000000000..4d35277a33 --- /dev/null +++ b/engines/titanic/game/maitred/maitred_arm_holder.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/maitred/maitred_arm_holder.h" + +namespace Titanic { + +void CMaitreDArmHolder::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CDropTarget::save(file, indent); +} + +void CMaitreDArmHolder::load(SimpleFile *file) { + file->readNumber(); + CDropTarget::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/maitred/maitred_arm_holder.h b/engines/titanic/game/maitred/maitred_arm_holder.h new file mode 100644 index 0000000000..3392d60e43 --- /dev/null +++ b/engines/titanic/game/maitred/maitred_arm_holder.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAITRED_ARM_HOLDER_H +#define TITANIC_MAITRED_ARM_HOLDER_H + +#include "titanic/core/drop_target.h" + +namespace Titanic { + +class CMaitreDArmHolder : public CDropTarget { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAITRED_ARM_HOLDER_H */ diff --git a/engines/titanic/game/maitred/maitred_body.cpp b/engines/titanic/game/maitred/maitred_body.cpp new file mode 100644 index 0000000000..6b495e5a1c --- /dev/null +++ b/engines/titanic/game/maitred/maitred_body.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/maitred/maitred_legs.h" + +namespace Titanic { + +void CMaitreDLegs::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldC8, indent); + CMaitreDProdReceptor::save(file, indent); +} + +void CMaitreDLegs::load(SimpleFile *file) { + file->readNumber(); + _fieldC8 = file->readNumber(); + CMaitreDProdReceptor::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/maitred/maitred_body.h b/engines/titanic/game/maitred/maitred_body.h new file mode 100644 index 0000000000..7016c15c71 --- /dev/null +++ b/engines/titanic/game/maitred/maitred_body.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAITRED_BODY_H +#define TITANIC_MAITRED_BODY_H + +#include "titanic/game/maitred/maitred_prod_receptor.h" + +namespace Titanic { + +class CMaitreDBody : public CMaitreDProdReceptor { +private: + int _fieldC8; +public: + CLASSDEF; + CMaitreDBody() : CMaitreDProdReceptor(), _fieldC8(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAITRED_BODY_H */ diff --git a/engines/titanic/game/maitred/maitred_legs.cpp b/engines/titanic/game/maitred/maitred_legs.cpp new file mode 100644 index 0000000000..5071805101 --- /dev/null +++ b/engines/titanic/game/maitred/maitred_legs.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/maitred/maitred_body.h" + +namespace Titanic { + +void CMaitreDBody::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldC8, indent); + CMaitreDProdReceptor::save(file, indent); +} + +void CMaitreDBody::load(SimpleFile *file) { + file->readNumber(); + _fieldC8 = file->readNumber(); + CMaitreDProdReceptor::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/maitred/maitred_legs.h b/engines/titanic/game/maitred/maitred_legs.h new file mode 100644 index 0000000000..24ba01e712 --- /dev/null +++ b/engines/titanic/game/maitred/maitred_legs.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAITRED_LEGS_H +#define TITANIC_MAITRED_LEGS_H + +#include "titanic/game/maitred/maitred_prod_receptor.h" + +namespace Titanic { + +class CMaitreDLegs : public CMaitreDProdReceptor { +private: + int _fieldC8; +public: + CLASSDEF; + CMaitreDLegs() : CMaitreDProdReceptor(), _fieldC8(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAITRED_LEGS_H */ diff --git a/engines/titanic/game/maitred/maitred_prod_receptor.cpp b/engines/titanic/game/maitred/maitred_prod_receptor.cpp new file mode 100644 index 0000000000..4823f143b0 --- /dev/null +++ b/engines/titanic/game/maitred/maitred_prod_receptor.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/maitred/maitred_prod_receptor.h" + +namespace Titanic { + +void CMaitreDProdReceptor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + + CGameObject::save(file, indent); +} + +void CMaitreDProdReceptor::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/maitred/maitred_prod_receptor.h b/engines/titanic/game/maitred/maitred_prod_receptor.h new file mode 100644 index 0000000000..f3a547b8ef --- /dev/null +++ b/engines/titanic/game/maitred/maitred_prod_receptor.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAITRED_PROD_RECEPTOR_H +#define TITANIC_MAITRED_PROD_RECEPTOR_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CMaitreDProdReceptor : public CGameObject { +protected: + int _fieldBC; + int _fieldC0; + int _fieldC4; +public: + CLASSDEF; + CMaitreDProdReceptor() : CGameObject(), + _fieldBC(0), _fieldC0(0), _fieldC4(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAITRED_PROD_RECEPTOR_H */ diff --git a/engines/titanic/game/missiveomat.cpp b/engines/titanic/game/missiveomat.cpp new file mode 100644 index 0000000000..931b146801 --- /dev/null +++ b/engines/titanic/game/missiveomat.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/missiveomat.h" + +namespace Titanic { + +CMissiveOMat::CMissiveOMat() : CGameObject(), _fieldBC(1), + _fieldC0(0), _fieldC4(0), _fieldE0(-1) { +} + +void CMissiveOMat::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_fieldE0, indent); + + CGameObject::save(file, indent); +} + +void CMissiveOMat::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + _fieldE0 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/missiveomat.h b/engines/titanic/game/missiveomat.h new file mode 100644 index 0000000000..7fde8cf25d --- /dev/null +++ b/engines/titanic/game/missiveomat.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MISSIVEOMAT_H +#define TITANIC_MISSIVEOMAT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CMissiveOMat : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; + CString _string1; + CString _string2; + int _fieldE0; +public: + CLASSDEF; + CMissiveOMat(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MISSIVEOMAT_H */ diff --git a/engines/titanic/game/missiveomat_button.cpp b/engines/titanic/game/missiveomat_button.cpp new file mode 100644 index 0000000000..d5ae75dbc2 --- /dev/null +++ b/engines/titanic/game/missiveomat_button.cpp @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/missiveomat_button.h" + +namespace Titanic { + +void CMissiveOMatButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldFC, indent); + + CEditControl::save(file, indent); +} + +void CMissiveOMatButton::load(SimpleFile *file) { + file->readNumber(); + _fieldFC = file->readNumber(); + + CEditControl::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/missiveomat_button.h b/engines/titanic/game/missiveomat_button.h new file mode 100644 index 0000000000..d36f5bd958 --- /dev/null +++ b/engines/titanic/game/missiveomat_button.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MISSIVEOMAT_BUTTON_H +#define TITANIC_MISSIVEOMAT_BUTTON_H + +#include "titanic/gfx/edit_control.h" + +namespace Titanic { + +class CMissiveOMatButton : public CEditControl { +public: + int _fieldFC; +public: + CLASSDEF; + CMissiveOMatButton() : CEditControl(), _fieldFC(2) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MISSIVEOMAT_BUTTON_H */ diff --git a/engines/titanic/game/movie_tester.cpp b/engines/titanic/game/movie_tester.cpp new file mode 100644 index 0000000000..1b266d9c7e --- /dev/null +++ b/engines/titanic/game/movie_tester.cpp @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/movie_tester.h" + +namespace Titanic { + +void CMovieTester::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + CGameObject::save(file, indent); +} + +void CMovieTester::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/movie_tester.h b/engines/titanic/game/movie_tester.h new file mode 100644 index 0000000000..de2ef2cc5e --- /dev/null +++ b/engines/titanic/game/movie_tester.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVIE_TESTER_H +#define TITANIC_MOVIE_TESTER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CMovieTester : public CGameObject { +public: + int _value1, _value2; +public: + CLASSDEF; + CMovieTester() : CGameObject(), _value1(0), _value2(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_TESTER_H */ diff --git a/engines/titanic/game/music_console_button.cpp b/engines/titanic/game/music_console_button.cpp new file mode 100644 index 0000000000..1bc78ffe23 --- /dev/null +++ b/engines/titanic/game/music_console_button.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/music_console_button.h" + +namespace Titanic { + +void CMusicConsoleButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicPlayer::save(file, indent); +} + +void CMusicConsoleButton::load(SimpleFile *file) { + file->readNumber(); + CMusicPlayer::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/music_console_button.h b/engines/titanic/game/music_console_button.h new file mode 100644 index 0000000000..8e05b698d7 --- /dev/null +++ b/engines/titanic/game/music_console_button.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_CONSOLE_BUTTON_H +#define TITANIC_MUSIC_CONSOLE_BUTTON_H + +#include "titanic/sound/music_player.h" + +namespace Titanic { + +class CMusicConsoleButton : public CMusicPlayer { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_CONSOLE_BUTTON_H */ diff --git a/engines/titanic/game/music_room_phonograph.cpp b/engines/titanic/game/music_room_phonograph.cpp new file mode 100644 index 0000000000..06a35dc4d5 --- /dev/null +++ b/engines/titanic/game/music_room_phonograph.cpp @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/music_room_phonograph.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CMusicRoomPhonograph, CRestaurantPhonograph); + +void CMusicRoomPhonograph::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field118, indent); + CRestaurantPhonograph::save(file, indent); +} + +void CMusicRoomPhonograph::load(SimpleFile *file) { + file->readNumber(); + _field118 = file->readNumber(); + CRestaurantPhonograph::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/music_room_phonograph.h b/engines/titanic/game/music_room_phonograph.h new file mode 100644 index 0000000000..9286861785 --- /dev/null +++ b/engines/titanic/game/music_room_phonograph.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_ROOM_PHONOGRAPH_H +#define TITANIC_MUSIC_ROOM_PHONOGRAPH_H + +#include "titanic/game/restaurant_phonograph.h" + +namespace Titanic { + +class CMusicRoomPhonograph : public CRestaurantPhonograph { + DECLARE_MESSAGE_MAP; +private: + int _field118; +public: + CLASSDEF; + CMusicRoomPhonograph() : CRestaurantPhonograph(), _field118(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_ROOM_PHONOGRAPH_H */ diff --git a/engines/titanic/game/music_room_stop_phonograph_button.cpp b/engines/titanic/game/music_room_stop_phonograph_button.cpp new file mode 100644 index 0000000000..44342fc2d6 --- /dev/null +++ b/engines/titanic/game/music_room_stop_phonograph_button.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/music_room_stop_phonograph_button.h" + +namespace Titanic { + +void CMusicRoomStopPhonographButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field100, indent); + CEjectPhonographButton::save(file, indent); +} + +void CMusicRoomStopPhonographButton::load(SimpleFile *file) { + file->readNumber(); + _field100 = file->readNumber(); + CEjectPhonographButton::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/music_room_stop_phonograph_button.h b/engines/titanic/game/music_room_stop_phonograph_button.h new file mode 100644 index 0000000000..7260e5aaab --- /dev/null +++ b/engines/titanic/game/music_room_stop_phonograph_button.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_ROOM_STOP_PHONOGRAPH_BUTTON_H +#define TITANIC_MUSIC_ROOM_STOP_PHONOGRAPH_BUTTON_H + +#include "titanic/game/eject_phonograph_button.h" + +namespace Titanic { + +class CMusicRoomStopPhonographButton : public CEjectPhonographButton { +private: + int _field100; +public: + CLASSDEF; + CMusicRoomStopPhonographButton() : CEjectPhonographButton(), _field100(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_ROOM_STOP_PHONOGRAPH_BUTTON_H */ diff --git a/engines/titanic/game/music_system_lock.cpp b/engines/titanic/game/music_system_lock.cpp new file mode 100644 index 0000000000..f1e062b3ee --- /dev/null +++ b/engines/titanic/game/music_system_lock.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/music_system_lock.h" + +namespace Titanic { + +void CMusicSystemLock::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CDropTarget::save(file, indent); +} + +void CMusicSystemLock::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CDropTarget::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/music_system_lock.h b/engines/titanic/game/music_system_lock.h new file mode 100644 index 0000000000..ff826f5c77 --- /dev/null +++ b/engines/titanic/game/music_system_lock.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_SYSTEM_LOCK_H +#define TITANIC_MUSIC_SYSTEM_LOCK_H + +#include "titanic/core/drop_target.h" + +namespace Titanic { + +class CMusicSystemLock : public CDropTarget { +private: + int _value; +public: + CLASSDEF; + CMusicSystemLock() : CDropTarget(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SYSTEM_LOCK_H */ diff --git a/engines/titanic/game/musical_instrument.cpp b/engines/titanic/game/musical_instrument.cpp new file mode 100644 index 0000000000..3bd2e37ccc --- /dev/null +++ b/engines/titanic/game/musical_instrument.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/musical_instrument.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CMusicalInstrument, CBackground); + +void CMusicalInstrument::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBackground::save(file, indent); +} + +void CMusicalInstrument::load(SimpleFile *file) { + file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/musical_instrument.h b/engines/titanic/game/musical_instrument.h new file mode 100644 index 0000000000..5d18ed91f0 --- /dev/null +++ b/engines/titanic/game/musical_instrument.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSICAL_INSTRUMENT_H +#define TITANIC_MUSICAL_INSTRUMENT_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CMusicalInstrument : public CBackground { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSICAL_INSTRUMENT_H */ diff --git a/engines/titanic/game/nav_helmet.cpp b/engines/titanic/game/nav_helmet.cpp new file mode 100644 index 0000000000..770eb7375e --- /dev/null +++ b/engines/titanic/game/nav_helmet.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/nav_helmet.h" + +namespace Titanic { + +void CNavHelmet::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CNavHelmet::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/nav_helmet.h b/engines/titanic/game/nav_helmet.h new file mode 100644 index 0000000000..74caa52534 --- /dev/null +++ b/engines/titanic/game/nav_helmet.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NAV_HELMET_H +#define TITANIC_NAV_HELMET_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CNavHelmet : public CGameObject { +private: + int _value; +public: + CLASSDEF; + CNavHelmet() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NAV_HELMET_H */ diff --git a/engines/titanic/game/navigation_computer.cpp b/engines/titanic/game/navigation_computer.cpp new file mode 100644 index 0000000000..49bd252988 --- /dev/null +++ b/engines/titanic/game/navigation_computer.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/navigation_computer.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CNavigationComputer, CGameObject); + +void CNavigationComputer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CNavigationComputer::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/navigation_computer.h b/engines/titanic/game/navigation_computer.h new file mode 100644 index 0000000000..27d06c1f27 --- /dev/null +++ b/engines/titanic/game/navigation_computer.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NAVIGATION_COMPUTER_H +#define TITANIC_NAVIGATION_COMPUTER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CNavigationComputer : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NAVIGATION_COMPUTER_H */ diff --git a/engines/titanic/game/no_nut_bowl.cpp b/engines/titanic/game/no_nut_bowl.cpp new file mode 100644 index 0000000000..47f9d7901e --- /dev/null +++ b/engines/titanic/game/no_nut_bowl.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/no_nut_bowl.h" + +namespace Titanic { + +void CNoNutBowl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBackground::save(file, indent); +} + +void CNoNutBowl::load(SimpleFile *file) { + file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/no_nut_bowl.h b/engines/titanic/game/no_nut_bowl.h new file mode 100644 index 0000000000..548b324869 --- /dev/null +++ b/engines/titanic/game/no_nut_bowl.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NO_NUT_BOWL_H +#define TITANIC_NO_NUT_BOWL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CNoNutBowl : public CBackground { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NO_NUT_BOWL_H */ diff --git a/engines/titanic/game/nose_holder.cpp b/engines/titanic/game/nose_holder.cpp new file mode 100644 index 0000000000..cd9433ee9c --- /dev/null +++ b/engines/titanic/game/nose_holder.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/nose_holder.h" + +namespace Titanic { + +CNoseHolder::CNoseHolder() : CDropTarget(), _field118(0), _field11C(0) { +} + +void CNoseHolder::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field11C, indent); + + CDropTarget::save(file, indent); +} + +void CNoseHolder::load(SimpleFile *file) { + file->readNumber(); + _field11C = file->readNumber(); + + CDropTarget::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/nose_holder.h b/engines/titanic/game/nose_holder.h new file mode 100644 index 0000000000..b8cca95869 --- /dev/null +++ b/engines/titanic/game/nose_holder.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NOSE_HOLDER_H +#define TITANIC_NOSE_HOLDER_H + +#include "titanic/core/drop_target.h" + +namespace Titanic { + +class CNoseHolder : public CDropTarget { +private: + int _field118; + int _field11C; +public: + CLASSDEF; + CNoseHolder(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NOSE_HOLDER_H */ diff --git a/engines/titanic/game/null_port_hole.cpp b/engines/titanic/game/null_port_hole.cpp new file mode 100644 index 0000000000..e651b1b59f --- /dev/null +++ b/engines/titanic/game/null_port_hole.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/null_port_hole.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CNullPortHole, CClickResponder); + +CNullPortHole::CNullPortHole() : CClickResponder() { + _string1 = "For a better view, why not visit the Promenade Deck?"; + _string2 = "b#48.wav"; +} + +void CNullPortHole::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string1, indent); + + CClickResponder::save(file, indent); +} + +void CNullPortHole::load(SimpleFile *file) { + file->readNumber(); + _string2 = file->readString(); + _string1 = file->readString(); + + CClickResponder::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/null_port_hole.h b/engines/titanic/game/null_port_hole.h new file mode 100644 index 0000000000..26564271b9 --- /dev/null +++ b/engines/titanic/game/null_port_hole.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NULL_PORT_HOLE_H +#define TITANIC_NULL_PORT_HOLE_H + +#include "titanic/core/click_responder.h" + +namespace Titanic { + +class CNullPortHole : public CClickResponder { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CNullPortHole(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NULL_PORT_HOLE_H */ diff --git a/engines/titanic/game/nut_replacer.cpp b/engines/titanic/game/nut_replacer.cpp new file mode 100644 index 0000000000..9a73355c91 --- /dev/null +++ b/engines/titanic/game/nut_replacer.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/nut_replacer.h" + +namespace Titanic { + +void CNutReplacer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CNutReplacer::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/nut_replacer.h b/engines/titanic/game/nut_replacer.h new file mode 100644 index 0000000000..ead9713801 --- /dev/null +++ b/engines/titanic/game/nut_replacer.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NUT_REPLACER_H +#define TITANIC_NUT_REPLACER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CNutReplacer : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NUT_REPLACER_H */ diff --git a/engines/titanic/game/parrot/parrot_lobby_controller.cpp b/engines/titanic/game/parrot/parrot_lobby_controller.cpp new file mode 100644 index 0000000000..f1e054a8dd --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_controller.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_lobby_controller.h" + +namespace Titanic { + +void CParrotLobbyController::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CParrotLobbyObject::save(file, indent); +} + +void CParrotLobbyController::load(SimpleFile *file) { + file->readNumber(); + CParrotLobbyObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_lobby_controller.h b/engines/titanic/game/parrot/parrot_lobby_controller.h new file mode 100644 index 0000000000..d2fa4a1801 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_controller.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_LOBBY_CONTROLLER_H +#define TITANIC_PARROT_LOBBY_CONTROLLER_H + +#include "titanic/game/parrot/parrot_lobby_object.h" + +namespace Titanic { + +class CParrotLobbyController : public CParrotLobbyObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_LOBBY_CONTROLLER_H */ diff --git a/engines/titanic/game/parrot/parrot_lobby_link_updater.cpp b/engines/titanic/game/parrot/parrot_lobby_link_updater.cpp new file mode 100644 index 0000000000..25d5ec724b --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_link_updater.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_lobby_link_updater.h" + +namespace Titanic { + +void CParrotLobbyLinkUpdater::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CParrotLobbyObject::save(file, indent); +} + +void CParrotLobbyLinkUpdater::load(SimpleFile *file) { + file->readNumber(); + CParrotLobbyObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_lobby_link_updater.h b/engines/titanic/game/parrot/parrot_lobby_link_updater.h new file mode 100644 index 0000000000..0470a62dee --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_link_updater.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_LOBBY_LINK_UPDATER_H +#define TITANIC_PARROT_LOBBY_LINK_UPDATER_H + +#include "titanic/game/parrot/parrot_lobby_object.h" + +namespace Titanic { + +class CParrotLobbyLinkUpdater : public CParrotLobbyObject { +public: + int _fieldBC; +public: + CLASSDEF; + CParrotLobbyLinkUpdater() : CParrotLobbyObject(), _fieldBC(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_LOBBY_LINK_UPDATER_H */ diff --git a/engines/titanic/game/parrot/parrot_lobby_object.cpp b/engines/titanic/game/parrot/parrot_lobby_object.cpp new file mode 100644 index 0000000000..a78ab2b6d9 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_object.cpp @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_lobby_object.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CParrotLobbyObject, CGameObject); + +int CParrotLobbyObject::_v1; +int CParrotLobbyObject::_v2; +int CParrotLobbyObject::_v3; +int CParrotLobbyObject::_v4; + +void CParrotLobbyObject::init() { + _v1 = 1; + _v2 = 1; + _v3 = 1; + _v4 = 7; +} + +void CParrotLobbyObject::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_v3, indent); + file->writeNumberLine(_v4, indent); + + CGameObject::save(file, indent); +} + +void CParrotLobbyObject::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _v3 = file->readNumber(); + _v4 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_lobby_object.h b/engines/titanic/game/parrot/parrot_lobby_object.h new file mode 100644 index 0000000000..5272303888 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_object.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_LOBBY_OBJECT_H +#define TITANIC_PARROT_LOBBY_OBJECT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CParrotLobbyObject : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + static int _v1; + static int _v2; + static int _v3; + static int _v4; + + static void init(); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_LOBBY_OBJECT_H */ diff --git a/engines/titanic/game/parrot/parrot_lobby_view_object.cpp b/engines/titanic/game/parrot/parrot_lobby_view_object.cpp new file mode 100644 index 0000000000..ae398036a8 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_view_object.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_lobby_view_object.h" + +namespace Titanic { + +void CParrotLobbyViewObject::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + CParrotLobbyObject::save(file, indent); +} + +void CParrotLobbyViewObject::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + CParrotLobbyObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_lobby_view_object.h b/engines/titanic/game/parrot/parrot_lobby_view_object.h new file mode 100644 index 0000000000..3179bb962d --- /dev/null +++ b/engines/titanic/game/parrot/parrot_lobby_view_object.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_LOBBY_VIEW_OBJECT_H +#define TITANIC_PARROT_LOBBY_VIEW_OBJECT_H + +#include "titanic/game/parrot/parrot_lobby_object.h" + +namespace Titanic { + +class CParrotLobbyViewObject : public CParrotLobbyObject { +public: + int _fieldBC; +public: + CLASSDEF; + CParrotLobbyViewObject() : CParrotLobbyObject(), _fieldBC(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_LOBBY_VIEW_OBJECT_H */ diff --git a/engines/titanic/game/parrot/parrot_loser.cpp b/engines/titanic/game/parrot/parrot_loser.cpp new file mode 100644 index 0000000000..6e23ef8314 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_loser.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_loser.h" + +namespace Titanic { + +void CParrotLoser::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CParrotLoser::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_loser.h b/engines/titanic/game/parrot/parrot_loser.h new file mode 100644 index 0000000000..819fd6614c --- /dev/null +++ b/engines/titanic/game/parrot/parrot_loser.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_LOSER_H +#define TITANIC_PARROT_LOSER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CParrotLoser : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_LOSER_H */ diff --git a/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp b/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp new file mode 100644 index 0000000000..c83d66cbdf --- /dev/null +++ b/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_nut_bowl_actor.h" + +namespace Titanic { + +CParrotNutBowlActor::CParrotNutBowlActor() : CGameObject(), + _value1(0), _value2(0) { +} + +void CParrotNutBowlActor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CParrotNutBowlActor::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_nut_bowl_actor.h b/engines/titanic/game/parrot/parrot_nut_bowl_actor.h new file mode 100644 index 0000000000..d8395bb65a --- /dev/null +++ b/engines/titanic/game/parrot/parrot_nut_bowl_actor.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_NUT_BOWL_ACTOR_H +#define TITANIC_PARROT_NUT_BOWL_ACTOR_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CParrotNutBowlActor : public CGameObject { +public: + int _value1, _value2; +public: + CLASSDEF; + CParrotNutBowlActor(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_NUT_BOWL_ACTOR_H */ diff --git a/engines/titanic/game/parrot/parrot_nut_eater.cpp b/engines/titanic/game/parrot/parrot_nut_eater.cpp new file mode 100644 index 0000000000..309b379ab8 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_nut_eater.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_nut_eater.h" + +namespace Titanic { + +CParrotNutEater::CParrotNutEater() : CGameObject(), _fieldBC(0), + _fieldC0(69), _fieldC4(132), _fieldC8(0), _fieldCC(68) { +} + +void CParrotNutEater::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + + CGameObject::save(file, indent); +} + +void CParrotNutEater::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_nut_eater.h b/engines/titanic/game/parrot/parrot_nut_eater.h new file mode 100644 index 0000000000..5dcb01ca11 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_nut_eater.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_NUT_EATER_H +#define TITANIC_PARROT_NUT_EATER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CParrotNutEater : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; +public: + CLASSDEF; + CParrotNutEater(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CREDITS_H */ diff --git a/engines/titanic/game/parrot/parrot_perch_holder.cpp b/engines/titanic/game/parrot/parrot_perch_holder.cpp new file mode 100644 index 0000000000..dd8523990b --- /dev/null +++ b/engines/titanic/game/parrot/parrot_perch_holder.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_perch_holder.h" + +namespace Titanic { + +void CParrotPerchHolder::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMultiDropTarget::save(file, indent); +} + +void CParrotPerchHolder::load(SimpleFile *file) { + file->readNumber(); + CMultiDropTarget::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_perch_holder.h b/engines/titanic/game/parrot/parrot_perch_holder.h new file mode 100644 index 0000000000..ff618f09dc --- /dev/null +++ b/engines/titanic/game/parrot/parrot_perch_holder.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_PERCH_HOLDER_H +#define TITANIC_PARROT_PERCH_HOLDER_H + +#include "titanic/core/multi_drop_target.h" + +namespace Titanic { + +class CParrotPerchHolder : public CMultiDropTarget { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_PERCH_HOLDER_H */ diff --git a/engines/titanic/game/parrot/parrot_succubus.cpp b/engines/titanic/game/parrot/parrot_succubus.cpp new file mode 100644 index 0000000000..02a29b748e --- /dev/null +++ b/engines/titanic/game/parrot/parrot_succubus.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_succubus.h" + +namespace Titanic { + +CParrotSuccUBus::CParrotSuccUBus() : CSuccUBus(), _field1DC(0), + _field1EC(0), _field1F0(376), _field1F4(393) { +} + +void CParrotSuccUBus::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field1DC, indent); + file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_field1EC, indent); + + CSuccUBus::save(file, indent); +} + +void CParrotSuccUBus::load(SimpleFile *file) { + file->readNumber(); + _field1DC = file->readNumber(); + _string3 = file->readString(); + _field1EC = file->readNumber(); + + CSuccUBus::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_succubus.h b/engines/titanic/game/parrot/parrot_succubus.h new file mode 100644 index 0000000000..6f5d9e602a --- /dev/null +++ b/engines/titanic/game/parrot/parrot_succubus.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_SUCCUBUS_H +#define TITANIC_PARROT_SUCCUBUS_H + +#include "titanic/npcs/succubus.h" + +namespace Titanic { + +class CParrotSuccUBus : public CSuccUBus { +public: + int _field1DC; + CString _string3; + int _field1EC; + int _field1F0; + int _field1F4; +public: + CLASSDEF; + CParrotSuccUBus(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_SUCCUBUS_H */ diff --git a/engines/titanic/game/parrot/parrot_trigger.cpp b/engines/titanic/game/parrot/parrot_trigger.cpp new file mode 100644 index 0000000000..36e99ada33 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_trigger.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/parrot_trigger.h" + +namespace Titanic { + +void CParrotTrigger::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CParrotTrigger::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_trigger.h b/engines/titanic/game/parrot/parrot_trigger.h new file mode 100644 index 0000000000..28a1663fa8 --- /dev/null +++ b/engines/titanic/game/parrot/parrot_trigger.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_TRIGGER_H +#define TITANIC_PARROT_TRIGGER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CParrotTrigger : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CParrotTrigger() : CGameObject(), _value(0x446AB) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_TRIGGER_H */ diff --git a/engines/titanic/game/parrot/player_meets_parrot.cpp b/engines/titanic/game/parrot/player_meets_parrot.cpp new file mode 100644 index 0000000000..6db9345bc0 --- /dev/null +++ b/engines/titanic/game/parrot/player_meets_parrot.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/parrot/player_meets_parrot.h" + +namespace Titanic { + +void CPlayerMeetsParrot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPlayerMeetsParrot::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +bool CPlayerMeetsParrot::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CPlayerMeetsParrot::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/parrot/player_meets_parrot.h b/engines/titanic/game/parrot/player_meets_parrot.h new file mode 100644 index 0000000000..9cee9ee322 --- /dev/null +++ b/engines/titanic/game/parrot/player_meets_parrot.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PLAYER_MEETS_PARROT_H +#define TITANIC_PLAYER_MEETS_PARROT_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CPlayerMeetsParrot : public CGameObject { +protected: + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PLAYER_MEETS_PARROT_H */ diff --git a/engines/titanic/game/pet/pet.cpp b/engines/titanic/game/pet/pet.cpp new file mode 100644 index 0000000000..cd4e16d38c --- /dev/null +++ b/engines/titanic/game/pet/pet.cpp @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet.h" + +namespace Titanic { + +CPET::CPET() : CGameObject(), _fieldBC(0), _fieldC0(3), + _fieldC4(0), _fieldC8(0), _fieldD8(0), _fieldDC(0) { +} + +void CPET::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_fieldD8, indent); + file->writeNumberLine(_fieldDC, indent); + + CGameObject::save(file, indent); +} + +void CPET::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _string1 = file->readString(); + _fieldD8 = file->readNumber(); + _fieldDC = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet.h b/engines/titanic/game/pet/pet.h new file mode 100644 index 0000000000..cdad649401 --- /dev/null +++ b/engines/titanic/game/pet/pet.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_H +#define TITANIC_PET_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPET : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + CString _string1; + int _fieldD8; + int _fieldDC; +public: + CLASSDEF; + CPET(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_H */ diff --git a/engines/titanic/game/pet/pet_class1.cpp b/engines/titanic/game/pet/pet_class1.cpp new file mode 100644 index 0000000000..651a8f9ed3 --- /dev/null +++ b/engines/titanic/game/pet/pet_class1.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_class1.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPETClass1, CGameObject); + +void CPETClass1::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETClass1::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_class1.h b/engines/titanic/game/pet/pet_class1.h new file mode 100644 index 0000000000..fb7a48b927 --- /dev/null +++ b/engines/titanic/game/pet/pet_class1.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_CLASS1_H +#define TITANIC_PET_CLASS1_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPETClass1 : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_CLASS1_H */ diff --git a/engines/titanic/game/pet/pet_class2.cpp b/engines/titanic/game/pet/pet_class2.cpp new file mode 100644 index 0000000000..e3e23f62ed --- /dev/null +++ b/engines/titanic/game/pet/pet_class2.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_class2.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPETClass2, CGameObject); + +void CPETClass2::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETClass2::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_class2.h b/engines/titanic/game/pet/pet_class2.h new file mode 100644 index 0000000000..c8855c82f3 --- /dev/null +++ b/engines/titanic/game/pet/pet_class2.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_CLASS2_H +#define TITANIC_PET_CLASS2_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPETClass2 : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_CLASS2_H */ diff --git a/engines/titanic/game/pet/pet_class3.cpp b/engines/titanic/game/pet/pet_class3.cpp new file mode 100644 index 0000000000..7751b994ab --- /dev/null +++ b/engines/titanic/game/pet/pet_class3.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_class3.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPETClass3, CGameObject); + +void CPETClass3::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETClass3::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_class3.h b/engines/titanic/game/pet/pet_class3.h new file mode 100644 index 0000000000..59d8389665 --- /dev/null +++ b/engines/titanic/game/pet/pet_class3.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_CLASS3_H +#define TITANIC_PET_CLASS3_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPETClass3 : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_CLASS3_H */ diff --git a/engines/titanic/game/pet/pet_lift.cpp b/engines/titanic/game/pet/pet_lift.cpp new file mode 100644 index 0000000000..39b0d01540 --- /dev/null +++ b/engines/titanic/game/pet/pet_lift.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_lift.h" + +namespace Titanic { + +void CPETLift::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPETTransport::save(file, indent); +} + +void CPETLift::load(SimpleFile *file) { + file->readNumber(); + CPETTransport::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_lift.h b/engines/titanic/game/pet/pet_lift.h new file mode 100644 index 0000000000..88b4e1c029 --- /dev/null +++ b/engines/titanic/game/pet/pet_lift.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_LIFT_H +#define TITANIC_PET_LIFT_H + +#include "titanic/game/pet/pet_transport.h" + +namespace Titanic { + +class CPETLift : public CPETTransport { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_LIFT_H */ diff --git a/engines/titanic/game/pet/pet_monitor.cpp b/engines/titanic/game/pet/pet_monitor.cpp new file mode 100644 index 0000000000..6a0d207a55 --- /dev/null +++ b/engines/titanic/game/pet/pet_monitor.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_monitor.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPETMonitor, CGameObject) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +void CPETMonitor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETMonitor::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +bool CPETMonitor::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CPETMonitor::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_monitor.h b/engines/titanic/game/pet/pet_monitor.h new file mode 100644 index 0000000000..61d1ba8ab6 --- /dev/null +++ b/engines/titanic/game/pet/pet_monitor.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_MONITOR_H +#define TITANIC_PET_MONITOR_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CPETMonitor : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_MONITOR_H */ diff --git a/engines/titanic/game/pet/pet_pellerator.cpp b/engines/titanic/game/pet/pet_pellerator.cpp new file mode 100644 index 0000000000..a29942ca59 --- /dev/null +++ b/engines/titanic/game/pet/pet_pellerator.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_pellerator.h" + +namespace Titanic { + +void CPETPellerator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPETTransport::save(file, indent); +} + +void CPETPellerator::load(SimpleFile *file) { + file->readNumber(); + CPETTransport::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_pellerator.h b/engines/titanic/game/pet/pet_pellerator.h new file mode 100644 index 0000000000..9b90c9af28 --- /dev/null +++ b/engines/titanic/game/pet/pet_pellerator.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_PELLERATOR_H +#define TITANIC_PET_PELLERATOR_H + +#include "titanic/game/pet/pet_transport.h" + +namespace Titanic { + +class CPETPellerator : public CPETTransport { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_PELLERATOR_H */ diff --git a/engines/titanic/game/pet/pet_position.cpp b/engines/titanic/game/pet/pet_position.cpp new file mode 100644 index 0000000000..d3d030eb16 --- /dev/null +++ b/engines/titanic/game/pet/pet_position.cpp @@ -0,0 +1,264 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_position.h" +#include "titanic/core/view_item.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPETPosition, CGameObject) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + +void CPETPosition::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETPosition::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +bool CPETPosition::EnterRoomMsg(CEnterRoomMsg *msg) { + if (msg->_newRoom->getName() == "EmbLobby") { + CPetControl *pet = getPetControl(); + if (pet) + pet->setRoomsFloorNum(1); + } + + return true; +} + +bool CPETPosition::EnterViewMsg(CEnterViewMsg *msg) { + CPetControl *pet = getPetControl(); + CString viewStr = msg->_newView->getNodeViewName(); + CString tempStr; + + if (compareRoomNameTo("TopOfWell")) { + tempStr = msg->_newView->getNodeViewName(); + int wellEntry = 0; + + if (tempStr == "Node 25.N") + wellEntry = 1; + else if (tempStr == "Node 24.SE") + wellEntry = 2; + else if (tempStr == "Node 26.N") + wellEntry = 3; + else if (tempStr == "Node 27.N") + wellEntry = 4; + + if (wellEntry != 0) + petSetRoomsWellEntry(wellEntry); + } else if (compareRoomNameTo("1stClassLobby")) { + int roomNum = 0; + + if (viewStr == "Node 2.N") + roomNum = 1; + else if (viewStr == "Node 3.N") + roomNum = 2; + else if (viewStr == "Node 4.N") + roomNum = 3; + else if (viewStr == "Node 5.N") + roomNum = 1; + else if (viewStr == "Node 6.N") + roomNum = 2; + else if (viewStr == "Node 7.N") + roomNum = 3; + + if (pet) { + pet->setRoomsRoomNum(roomNum); + pet->resetRoomsHighlight(); + + int elevatorNum = pet->getRoomsElevatorNum(); + int wellEntry = 0; + + if (viewStr == "Node 10.S") + wellEntry = (elevatorNum == 1 || elevatorNum == 2) ? 1 : 3; + else if (viewStr == "Node 9.S") + wellEntry = (elevatorNum == 1 || elevatorNum == 2) ? 2 : 4; + + if (wellEntry) + petSetRoomsWellEntry(wellEntry); + } + } else if (compareRoomNameTo("2ndClassLobby")) { + int roomNum = 0; + + if (viewStr == "Node 3.N") + roomNum = 1; + else if (viewStr == "Node 4.N") + roomNum = 2; + else if (viewStr == "Node 5.N") + roomNum = 3; + else if (viewStr == "Node 6.N") + roomNum = 4; + + if (pet) { + pet->setRoomsRoomNum(roomNum); + pet->resetRoomsHighlight(); + + int elevatorNum = pet->getRoomsElevatorNum(); + int wellEntry = 0; + + if (viewStr == "Node 8.S") + wellEntry = (elevatorNum == 1 || elevatorNum == 2) ? 1 : 3; + else if (viewStr == "Node 1.S") + wellEntry = (elevatorNum == 1 || elevatorNum == 2) ? 2 : 4; + + if (wellEntry) + petSetRoomsWellEntry(wellEntry); + } + } else if (compareRoomNameTo("SecClassLittleLift")) { + if (pet && viewStr == "Node 1.N") + pet->resetRoomsHighlight(); + } else if (compareRoomNameTo("SGTLittleLift")) { + if (pet && viewStr == "Node 1.N") + pet->resetRoomsHighlight(); + } else if (compareRoomNameTo("SgtLobby")) { + int roomNum = 0; + + if (viewStr == "Node 4.N") + roomNum = 1; + else if (viewStr == "Node 5.N") + roomNum = 2; + else if (viewStr == "Node 6.N") + roomNum = 3; + else if (viewStr == "Node 7.N") + roomNum = 4; + else if (viewStr == "Node 8.N") + roomNum = 5; + else if (viewStr == "Node 9.N") + roomNum = 6; + + if (pet) { + pet->setRooms1CC(1); + pet->setRoomsRoomNum(roomNum); + + if (viewStr == "Node 1.S") + pet->setRoomsWellEntry(pet->getRoomsElevatorNum()); + } + } else if (compareRoomNameTo("BottomOfWell")) { + if (viewStr == "Node 10.E") + petSetRoomsWellEntry(3); + else if (viewStr == "Node 11.W") + petSetRoomsWellEntry(1); + } + + return true; +} + +bool CPETPosition::LeaveViewMsg(CLeaveViewMsg *msg) { + CPetControl *pet = getPetControl(); + CString oldView = msg->_oldView->getName(); + CString newView = msg->_newView->getName(); + + if (pet && newView == "Lift.Node 1.N") { + int elevatorNum = pet->getRoomsElevatorNum(); + + if (oldView == "TopOfWell.Node 25.N") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(1); + return true; + } else if (oldView == "TopOfWell.Node 24.SE") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(2); + return true; + } else if (oldView == "TopOfWell.Node 26.N") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(3); + return true; + } else if (oldView == "TopOfWell.Node 27.N") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(4); + return true; + } else if (oldView == "1stClassLobby.Node 10.S") { + switch (elevatorNum) { + case 1: + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(1); + break; + case 2: + pet->setRoomsElevatorNum(1); + break; + default: + pet->setRoomsElevatorNum(3); + break; + } + return true; + } else if (oldView == "1stClassLobby.Node 9.S") { + switch (elevatorNum) { + case 1: + case 2: + pet->setRoomsElevatorNum(2); + break; + default: + pet->setRoomsElevatorNum(4); + break; + } + return true; + } else if (oldView == "2ndClassLobby.Node 8.S") { + switch (elevatorNum) { + case 1: + case 2: + pet->setRoomsElevatorNum(1); + break; + default: + pet->setRoomsElevatorNum(3); + break; + } + return true; + } else if (oldView == "2ndClassLobby.Node 1.S") { + switch (elevatorNum) { + case 1: + case 2: + pet->setRoomsElevatorNum(2); + break; + default: + pet->setRoomsElevatorNum(4); + break; + } + return true; + } else if (oldView == "SgtLobby.Node 1.S") { + return true; + } else if (oldView == "BottomOfWell.Node 10.E" || oldView == "BottomOfWell.Node 11.W") { + pet->setRoomsElevatorNum(1); + return true; + } + } + + CRoomItem *newRoom = msg->_newView->findRoom(); + if (newRoom) { + CString roomName = newRoom->getName(); + if (roomName == "1stClassLobby" || roomName == "2ndClassLobby" || roomName == "SgtLobby") { + if (pet) + pet->resetRoomsHighlight(); + } + } + + return true; +} + + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_position.h b/engines/titanic/game/pet/pet_position.h new file mode 100644 index 0000000000..0cf835f23f --- /dev/null +++ b/engines/titanic/game/pet/pet_position.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_POSITION_H +#define TITANIC_PET_POSITION_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CPETPosition : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_POSITION_H */ diff --git a/engines/titanic/game/pet/pet_sentinal.cpp b/engines/titanic/game/pet/pet_sentinal.cpp new file mode 100644 index 0000000000..1b647d7c62 --- /dev/null +++ b/engines/titanic/game/pet/pet_sentinal.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_sentinal.h" + +namespace Titanic { + +void CPETSentinal::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETSentinal::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_sentinal.h b/engines/titanic/game/pet/pet_sentinal.h new file mode 100644 index 0000000000..f7f9fef0ba --- /dev/null +++ b/engines/titanic/game/pet/pet_sentinal.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_SENTINAL_H +#define TITANIC_PET_SENTINAL_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPETSentinal : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_SENTINAL_H */ diff --git a/engines/titanic/game/pet/pet_sounds.cpp b/engines/titanic/game/pet/pet_sounds.cpp new file mode 100644 index 0000000000..d612c745bb --- /dev/null +++ b/engines/titanic/game/pet/pet_sounds.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_sounds.h" + +namespace Titanic { + +void CPETSounds::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CPETSounds::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_sounds.h b/engines/titanic/game/pet/pet_sounds.h new file mode 100644 index 0000000000..1d3acdb5f3 --- /dev/null +++ b/engines/titanic/game/pet/pet_sounds.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_SOUNDS_H +#define TITANIC_PET_SOUNDS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPETSounds : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CPETSounds() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_SOUNDS_H */ diff --git a/engines/titanic/game/pet/pet_transition.cpp b/engines/titanic/game/pet/pet_transition.cpp new file mode 100644 index 0000000000..33cc36ca11 --- /dev/null +++ b/engines/titanic/game/pet/pet_transition.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_transition.h" + +namespace Titanic { + +void CPETTransition::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETTransition::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_transition.h b/engines/titanic/game/pet/pet_transition.h new file mode 100644 index 0000000000..4abf16d509 --- /dev/null +++ b/engines/titanic/game/pet/pet_transition.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_TRANSITION_H +#define TITANIC_PET_TRANSITION_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPETTransition : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_TRANSITION_H */ diff --git a/engines/titanic/game/pet/pet_transport.cpp b/engines/titanic/game/pet/pet_transport.cpp new file mode 100644 index 0000000000..9661cace2c --- /dev/null +++ b/engines/titanic/game/pet/pet_transport.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_transport.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPETTransport, CGameObject) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +void CPETTransport::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPETTransport::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +bool CPETTransport::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CPETTransport::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_transport.h b/engines/titanic/game/pet/pet_transport.h new file mode 100644 index 0000000000..58aefe6743 --- /dev/null +++ b/engines/titanic/game/pet/pet_transport.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_TRANSPORT_H +#define TITANIC_PET_TRANSPORT_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CPETTransport : public CGameObject { + DECLARE_MESSAGE_MAP; + virtual bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_TRANSPORT_H */ diff --git a/engines/titanic/game/pet/pet_val_base.cpp b/engines/titanic/game/pet/pet_val_base.cpp new file mode 100644 index 0000000000..d77f366436 --- /dev/null +++ b/engines/titanic/game/pet/pet_val_base.cpp @@ -0,0 +1,31 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet/pet_val_base.h" + +namespace Titanic { + +CPetValBase::CPetValBase() : _field4(0), _field8(0), + _fieldC(0), _field10(0), _field14(0) { +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_val_base.h b/engines/titanic/game/pet/pet_val_base.h new file mode 100644 index 0000000000..cdb2808108 --- /dev/null +++ b/engines/titanic/game/pet/pet_val_base.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_pet_element_H +#define TITANIC_pet_element_H + +namespace Titanic { + +class CPetElement { +protected: + int _field4; + int _field8; + int _fieldC; + int _field10; + int _field14; +public: + CPetElement(); + + virtual void proc1() {} + virtual void proc2() {} + virtual void proc3() {} + virtual void proc4() {} + + virtual void proc5() {} + + virtual void proc6() {} + virtual void proc7() {} + virtual void proc8() {} + virtual void proc9() {} + virtual void proc10() {} + virtual void proc11() {} + virtual void proc12() {} + virtual void proc13() {} + virtual void proc14() {} + virtual void proc15() {} + virtual void proc16() {} + virtual void proc17() {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_pet_element_H */ diff --git a/engines/titanic/game/pet_disabler.cpp b/engines/titanic/game/pet_disabler.cpp new file mode 100644 index 0000000000..2275156503 --- /dev/null +++ b/engines/titanic/game/pet_disabler.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pet_disabler.h" + +namespace Titanic { + +void CPetDisabler::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_value, indent); + CGameObject::save(file, indent); +} + +void CPetDisabler::load(SimpleFile *file) { + file->readNumber(); + _value = file->readString(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pet_disabler.h b/engines/titanic/game/pet_disabler.h new file mode 100644 index 0000000000..92b4dff0a8 --- /dev/null +++ b/engines/titanic/game/pet_disabler.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_DISABLER_H +#define TITANIC_PET_DISABLER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPetDisabler : public CGameObject { +public: + CString _value; +public: + CLASSDEF; + CPetDisabler() : CGameObject() {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_DISABLER_H */ diff --git a/engines/titanic/game/phonograph.cpp b/engines/titanic/game/phonograph.cpp new file mode 100644 index 0000000000..9740e29273 --- /dev/null +++ b/engines/titanic/game/phonograph.cpp @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/phonograph.h" + +namespace Titanic { + +CPhonograph::CPhonograph() : CMusicPlayer(), + _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0), + _fieldF0(0), _fieldF4(0) { +} + +void CPhonograph::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + + CMusicPlayer::save(file, indent); +} + +void CPhonograph::load(SimpleFile *file) { + file->readNumber(); + _string2 = file->readString(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + + CMusicPlayer::load(file); +} + +bool CPhonograph::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CPhonograph::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/phonograph.h b/engines/titanic/game/phonograph.h new file mode 100644 index 0000000000..274d4ba367 --- /dev/null +++ b/engines/titanic/game/phonograph.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PHONOGRAPH_H +#define TITANIC_PHONOGRAPH_H + +#include "titanic/sound/music_player.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CPhonograph : public CMusicPlayer { + bool EnterRoomMsg(CEnterRoomMsg *msg); +protected: + CString _string2; + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; + int _fieldF4; +public: + CLASSDEF; + CPhonograph(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_CONSOLE_BUTTON_H */ diff --git a/engines/titanic/game/phonograph_lid.cpp b/engines/titanic/game/phonograph_lid.cpp new file mode 100644 index 0000000000..a0518420f7 --- /dev/null +++ b/engines/titanic/game/phonograph_lid.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/phonograph_lid.h" + +namespace Titanic { + +void CPhonographLid::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CPhonographLid::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/phonograph_lid.h b/engines/titanic/game/phonograph_lid.h new file mode 100644 index 0000000000..ab32be268b --- /dev/null +++ b/engines/titanic/game/phonograph_lid.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PHONOGRAPH_LID_H +#define TITANIC_PHONOGRAPH_LID_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPhonographLid : public CGameObject { +private: + int _value; +public: + CLASSDEF; + CPhonographLid() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PHONOGRAPH_LID_H */ diff --git a/engines/titanic/game/pickup/pick_up.cpp b/engines/titanic/game/pickup/pick_up.cpp new file mode 100644 index 0000000000..c660a36a32 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pickup/pick_up.h" + +namespace Titanic { + +void CPickUp::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + CGameObject::save(file, indent); +} + +void CPickUp::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up.h b/engines/titanic/game/pickup/pick_up.h new file mode 100644 index 0000000000..f0b6794442 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PICK_UP_H +#define TITANIC_PICK_UP_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPickUp : public CGameObject { +private: + int _fieldBC; +public: + CLASSDEF; + CPickUp() : CGameObject(), _fieldBC(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ANNOY_BARBOT_H */ diff --git a/engines/titanic/game/pickup/pick_up_bar_glass.cpp b/engines/titanic/game/pickup/pick_up_bar_glass.cpp new file mode 100644 index 0000000000..85b883281e --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_bar_glass.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pickup/pick_up_bar_glass.h" + +namespace Titanic { + +void CPickUpBarGlass::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPickUp::save(file, indent); +} + +void CPickUpBarGlass::load(SimpleFile *file) { + file->readNumber(); + CPickUp::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_bar_glass.h b/engines/titanic/game/pickup/pick_up_bar_glass.h new file mode 100644 index 0000000000..b5ef6f5a47 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_bar_glass.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PICK_UP_BAR_GLASS_H +#define TITANIC_PICK_UP_BAR_GLASS_H + +#include "titanic/game/pickup/pick_up.h" + +namespace Titanic { + +class CPickUpBarGlass : public CPickUp { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PICK_UP_BAR_GLASS_H */ diff --git a/engines/titanic/game/pickup/pick_up_hose.cpp b/engines/titanic/game/pickup/pick_up_hose.cpp new file mode 100644 index 0000000000..7375ddaa63 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_hose.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pickup/pick_up_hose.h" + +namespace Titanic { + +int CPickUpHose::_v1; + +void CPickUpHose::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_v1, indent); + + CPickUp::save(file, indent); +} + +void CPickUpHose::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _v1 = file->readNumber(); + + CPickUp::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_hose.h b/engines/titanic/game/pickup/pick_up_hose.h new file mode 100644 index 0000000000..80ccedc845 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_hose.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PICK_UP_HOSE_H +#define TITANIC_PICK_UP_HOSE_H + +#include "titanic/game/pickup/pick_up.h" + +namespace Titanic { + +class CPickUpHose : public CPickUp { +private: + static int _v1; + + CString _string1; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PICK_UP_HOSE_H */ diff --git a/engines/titanic/game/pickup/pick_up_lemon.cpp b/engines/titanic/game/pickup/pick_up_lemon.cpp new file mode 100644 index 0000000000..772114f76c --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_lemon.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pickup/pick_up_lemon.h" + +namespace Titanic { + +void CPickUpLemon::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPickUp::save(file, indent); +} + +void CPickUpLemon::load(SimpleFile *file) { + file->readNumber(); + CPickUp::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_lemon.h b/engines/titanic/game/pickup/pick_up_lemon.h new file mode 100644 index 0000000000..0312c71012 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_lemon.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PICK_UP_LEMON_H +#define TITANIC_PICK_UP_LEMON_H + +#include "titanic/game/pickup/pick_up.h" + +namespace Titanic { + +class CPickUpLemon : public CPickUp { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PICK_UP_LEMON_H */ diff --git a/engines/titanic/game/pickup/pick_up_speech_centre.cpp b/engines/titanic/game/pickup/pick_up_speech_centre.cpp new file mode 100644 index 0000000000..0b9a8d2c48 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_speech_centre.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pickup/pick_up_speech_centre.h" + +namespace Titanic { + +void CPickUpSpeechCentre::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPickUp::save(file, indent); +} + +void CPickUpSpeechCentre::load(SimpleFile *file) { + file->readNumber(); + CPickUp::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_speech_centre.h b/engines/titanic/game/pickup/pick_up_speech_centre.h new file mode 100644 index 0000000000..29dce04fb3 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_speech_centre.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PICK_UP_SPEECH_CENTRE_H +#define TITANIC_PICK_UP_SPEECH_CENTRE_H + +#include "titanic/game/pickup/pick_up.h" + +namespace Titanic { + +class CPickUpSpeechCentre : public CPickUp { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PICK_UP_SPEECH_CENTRE_H */ diff --git a/engines/titanic/game/pickup/pick_up_vis_centre.cpp b/engines/titanic/game/pickup/pick_up_vis_centre.cpp new file mode 100644 index 0000000000..796e46778c --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_vis_centre.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/pickup/pick_up_vis_centre.h" + +namespace Titanic { + +void CPickUpVisCentre::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPickUp::save(file, indent); +} + +void CPickUpVisCentre::load(SimpleFile *file) { + file->readNumber(); + CPickUp::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_vis_centre.h b/engines/titanic/game/pickup/pick_up_vis_centre.h new file mode 100644 index 0000000000..4f808f73c5 --- /dev/null +++ b/engines/titanic/game/pickup/pick_up_vis_centre.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PICK_UP_VIS_CENTRE_H +#define TITANIC_PICK_UP_VIS_CENTRE_H + +#include "titanic/game/pickup/pick_up.h" + +namespace Titanic { + +class CPickUpVisCentre : public CPickUp { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PICK_UP_VIS_CENTRE_H */ diff --git a/engines/titanic/game/placeholder/bar_shelf_vis_centre.cpp b/engines/titanic/game/placeholder/bar_shelf_vis_centre.cpp new file mode 100644 index 0000000000..a8a33fe1b1 --- /dev/null +++ b/engines/titanic/game/placeholder/bar_shelf_vis_centre.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/placeholder/bar_shelf_vis_centre.h" + +namespace Titanic { + +void CBarShelfVisCentre::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CPlaceHolderItem::save(file, indent); +} + +void CBarShelfVisCentre::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CPlaceHolderItem::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/bar_shelf_vis_centre.h b/engines/titanic/game/placeholder/bar_shelf_vis_centre.h new file mode 100644 index 0000000000..a53ef2633f --- /dev/null +++ b/engines/titanic/game/placeholder/bar_shelf_vis_centre.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BAR_SHELF_VIS_CENTRE_H +#define TITANIC_BAR_SHELF_VIS_CENTRE_H + +#include "titanic/game/placeholder/place_holder_item.h" + +namespace Titanic { + +class CBarShelfVisCentre : public CPlaceHolderItem { +private: + int _value; +public: + CLASSDEF; + CBarShelfVisCentre() : CPlaceHolderItem(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BAR_SHELF_VIS_CENTRE_H */ diff --git a/engines/titanic/game/placeholder/lemon_on_bar.cpp b/engines/titanic/game/placeholder/lemon_on_bar.cpp new file mode 100644 index 0000000000..08d686e81a --- /dev/null +++ b/engines/titanic/game/placeholder/lemon_on_bar.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/placeholder/lemon_on_bar.h" + +namespace Titanic { + +void CLemonOnBar::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writePoint(_pos1, indent); + CPlaceHolderItem::save(file, indent); +} + +void CLemonOnBar::load(SimpleFile *file) { + file->readNumber(); + _pos1 = file->readPoint(); + CPlaceHolderItem::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/lemon_on_bar.h b/engines/titanic/game/placeholder/lemon_on_bar.h new file mode 100644 index 0000000000..92dd54c49b --- /dev/null +++ b/engines/titanic/game/placeholder/lemon_on_bar.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LEMON_ON_BAR_H +#define TITANIC_LEMON_ON_BAR_H + +#include "titanic/game/placeholder/place_holder_item.h" + +namespace Titanic { + +class CLemonOnBar : public CPlaceHolderItem { +private: + Point _pos1; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LEMON_ON_BAR_H */ diff --git a/engines/titanic/game/placeholder/place_holder_item.cpp b/engines/titanic/game/placeholder/place_holder_item.cpp new file mode 100644 index 0000000000..365e8cbe50 --- /dev/null +++ b/engines/titanic/game/placeholder/place_holder_item.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/placeholder/place_holder_item.h" + +namespace Titanic { + +void CPlaceHolderItem::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPlaceHolderItem::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/place_holder_item.h b/engines/titanic/game/placeholder/place_holder_item.h new file mode 100644 index 0000000000..de04a64bf7 --- /dev/null +++ b/engines/titanic/game/placeholder/place_holder_item.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PLACE_HOLDER_H +#define TITANIC_PLACE_HOLDER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPlaceHolderItem : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PLACE_HOLDER_H */ diff --git a/engines/titanic/game/placeholder/tv_on_bar.cpp b/engines/titanic/game/placeholder/tv_on_bar.cpp new file mode 100644 index 0000000000..efbbe50461 --- /dev/null +++ b/engines/titanic/game/placeholder/tv_on_bar.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/placeholder/tv_on_bar.h" + +namespace Titanic { + +void CTVOnBar::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writePoint(_pos1, indent); + CPlaceHolderItem::save(file, indent); +} + +void CTVOnBar::load(SimpleFile *file) { + file->readNumber(); + _pos1 = file->readPoint(); + CPlaceHolderItem::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/tv_on_bar.h b/engines/titanic/game/placeholder/tv_on_bar.h new file mode 100644 index 0000000000..d41d972e73 --- /dev/null +++ b/engines/titanic/game/placeholder/tv_on_bar.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TV_ON_BAR_H +#define TITANIC_TV_ON_BAR_H + +#include "titanic/game/placeholder/place_holder_item.h" + +namespace Titanic { + +class CTVOnBar : public CPlaceHolderItem { +private: + Point _pos1; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TV_ON_BAR_H */ diff --git a/engines/titanic/game/play_music_button.cpp b/engines/titanic/game/play_music_button.cpp new file mode 100644 index 0000000000..8066739f10 --- /dev/null +++ b/engines/titanic/game/play_music_button.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/play_music_button.h" + +namespace Titanic { + +void CPlayMusicButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + + CBackground::save(file, indent); +} + +void CPlayMusicButton::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/play_music_button.h b/engines/titanic/game/play_music_button.h new file mode 100644 index 0000000000..4e3474181c --- /dev/null +++ b/engines/titanic/game/play_music_button.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PLAY_MUSIC_BUTTON_H +#define TITANIC_PLAY_MUSIC_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CPlayMusicButton : public CBackground { +public: + int _fieldE0; + int _fieldE4; +public: + CLASSDEF; + CPlayMusicButton() : CBackground(), _fieldE0(0), _fieldE4(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PLAY_MUSIC_BUTTON_H */ diff --git a/engines/titanic/game/play_on_act.cpp b/engines/titanic/game/play_on_act.cpp new file mode 100644 index 0000000000..e1ef1201c6 --- /dev/null +++ b/engines/titanic/game/play_on_act.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/play_on_act.h" + +namespace Titanic { + +void CPlayOnAct::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBackground::save(file, indent); +} + +void CPlayOnAct::load(SimpleFile *file) { + file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/play_on_act.h b/engines/titanic/game/play_on_act.h new file mode 100644 index 0000000000..197e647943 --- /dev/null +++ b/engines/titanic/game/play_on_act.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PLAY_ON_ACT_H +#define TITANIC_PLAY_ON_ACT_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CPlayOnAct : public CBackground { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PLAY_ON_ACT_H */ diff --git a/engines/titanic/game/port_hole.cpp b/engines/titanic/game/port_hole.cpp new file mode 100644 index 0000000000..f3c447f443 --- /dev/null +++ b/engines/titanic/game/port_hole.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/port_hole.h" + +namespace Titanic { + +CPortHole::CPortHole() : CGameObject(), _fieldBC(0), + _string1("b#47.wav"), _string2("b#46.wav") { +} + +void CPortHole::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + + CGameObject::save(file, indent); +} + +void CPortHole::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/port_hole.h b/engines/titanic/game/port_hole.h new file mode 100644 index 0000000000..7bba18d12a --- /dev/null +++ b/engines/titanic/game/port_hole.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PORT_HOLE_H +#define TITANIC_PORT_HOLE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPortHole : public CGameObject { +private: + int _fieldBC; + CString _string1, _string2; +public: + CLASSDEF; + CPortHole(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PORT_HOLE_H */ diff --git a/engines/titanic/game/record_phonograph_button.cpp b/engines/titanic/game/record_phonograph_button.cpp new file mode 100644 index 0000000000..f022957dbb --- /dev/null +++ b/engines/titanic/game/record_phonograph_button.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/record_phonograph_button.h" + +namespace Titanic { + +void CRecordPhonographButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CBackground::save(file, indent); +} + +void CRecordPhonographButton::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/record_phonograph_button.h b/engines/titanic/game/record_phonograph_button.h new file mode 100644 index 0000000000..3383c01e31 --- /dev/null +++ b/engines/titanic/game/record_phonograph_button.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RECORD_PHONOGRAPH_BUTTON_H +#define TITANIC_RECORD_PHONOGRAPH_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CRecordPhonographButton : public CBackground { +public: + int _value; +public: + CLASSDEF; + CRecordPhonographButton() : CBackground(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RECORD_PHONOGRAPH_BUTTON_H */ diff --git a/engines/titanic/game/replacement_ear.cpp b/engines/titanic/game/replacement_ear.cpp new file mode 100644 index 0000000000..1f9960365d --- /dev/null +++ b/engines/titanic/game/replacement_ear.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/replacement_ear.h" + +namespace Titanic { + +void CReplacementEar::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBackground::save(file, indent); +} + +void CReplacementEar::load(SimpleFile *file) { + file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/replacement_ear.h b/engines/titanic/game/replacement_ear.h new file mode 100644 index 0000000000..0d282b7fb4 --- /dev/null +++ b/engines/titanic/game/replacement_ear.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_REPLACEMENT_EAR_H +#define TITANIC_REPLACEMENT_EAR_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CReplacementEar : public CBackground { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_REPLACEMENT_EAR_H */ diff --git a/engines/titanic/game/reserved_table.cpp b/engines/titanic/game/reserved_table.cpp new file mode 100644 index 0000000000..a600190709 --- /dev/null +++ b/engines/titanic/game/reserved_table.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/reserved_table.h" + +namespace Titanic { + +void CReservedTable::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CReservedTable::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/reserved_table.h b/engines/titanic/game/reserved_table.h new file mode 100644 index 0000000000..a3532c7d14 --- /dev/null +++ b/engines/titanic/game/reserved_table.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RESERVED_TABLE_H +#define TITANIC_RESERVED_TABLE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CReservedTable : public CGameObject { +public: + int _value1, _value2; +public: + CLASSDEF; + CReservedTable() : CGameObject(), _value1(0), _value2(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RESERVED_TABLE_H */ diff --git a/engines/titanic/game/restaurant_cylinder_holder.cpp b/engines/titanic/game/restaurant_cylinder_holder.cpp new file mode 100644 index 0000000000..d70009f151 --- /dev/null +++ b/engines/titanic/game/restaurant_cylinder_holder.cpp @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/restaurant_cylinder_holder.h" + +namespace Titanic { + +CRestaurantCylinderHolder::CRestaurantCylinderHolder() : CDropTarget(), + _field118(0), _field11C(0), _field12C(0), _field130(0), + _string6("z#61.wav"), _field140(1) { +} + +void CRestaurantCylinderHolder::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field118, indent); + file->writeNumberLine(_field11C, indent); + file->writeQuotedLine(_string5, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_field130, indent); + file->writeQuotedLine(_string6, indent); + file->writeNumberLine(_field140, indent); + + CDropTarget::save(file, indent); +} + +void CRestaurantCylinderHolder::load(SimpleFile *file) { + file->readNumber(); + _field118 = file->readNumber(); + _field11C = file->readNumber(); + _string5 = file->readString(); + _field12C = file->readNumber(); + _field130 = file->readNumber(); + _string6 = file->readString(); + _field140 = file->readNumber(); + + CDropTarget::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/restaurant_cylinder_holder.h b/engines/titanic/game/restaurant_cylinder_holder.h new file mode 100644 index 0000000000..3aa979b0a5 --- /dev/null +++ b/engines/titanic/game/restaurant_cylinder_holder.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RESTAURANT_CYLINDER_HOLDER_H +#define TITANIC_RESTAURANT_CYLINDER_HOLDER_H + +#include "titanic/core/drop_target.h" + +namespace Titanic { + +class CRestaurantCylinderHolder : public CDropTarget { +private: + int _field118; + int _field11C; + CString _string5; + int _field12C; + int _field130; + CString _string6; + int _field140; +public: + CLASSDEF; + CRestaurantCylinderHolder(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RESTAURANT_CYLINDER_HOLDER_H */ diff --git a/engines/titanic/game/restaurant_phonograph.cpp b/engines/titanic/game/restaurant_phonograph.cpp new file mode 100644 index 0000000000..83a4ac3e71 --- /dev/null +++ b/engines/titanic/game/restaurant_phonograph.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/restaurant_phonograph.h" + +namespace Titanic { + +CRestaurantPhonograph::CRestaurantPhonograph() : CPhonograph(), + _fieldF8(1), _field114(0) {} + +void CRestaurantPhonograph::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string3, indent); + + file->writeNumberLine(_field114, indent); + + CPhonograph::save(file, indent); +} + +void CRestaurantPhonograph::load(SimpleFile *file) { + file->readNumber(); + _fieldF8 = file->readNumber(); + _string2 = file->readString(); + _string3 = file->readString(); + _field114 = file->readNumber(); + + CPhonograph::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/restaurant_phonograph.h b/engines/titanic/game/restaurant_phonograph.h new file mode 100644 index 0000000000..710a2edd73 --- /dev/null +++ b/engines/titanic/game/restaurant_phonograph.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RESTAURANT_PHONOGRAPH_H +#define TITANIC_RESTAURANT_PHONOGRAPH_H + +#include "titanic/game/phonograph.h" + +namespace Titanic { + +class CRestaurantPhonograph : public CPhonograph { +private: + int _fieldF8; + CString _string2; + CString _string3; + int _field114; +public: + CLASSDEF; + CRestaurantPhonograph(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RESTAURANT_PHONOGRAPH_H */ diff --git a/engines/titanic/game/sauce_dispensor.cpp b/engines/titanic/game/sauce_dispensor.cpp new file mode 100644 index 0000000000..8dc818d917 --- /dev/null +++ b/engines/titanic/game/sauce_dispensor.cpp @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sauce_dispensor.h" + +namespace Titanic { + +CSauceDispensor::CSauceDispensor() : CBackground(), + _fieldEC(0), _fieldF0(0), _field104(0), _field108(0) { +} + +void CSauceDispensor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_fieldF0, indent); + file->writePoint(_pos1, indent); + file->writePoint(_pos2, indent); + file->writeNumberLine(_field104, indent); + file->writeNumberLine(_field108, indent); + + CBackground::save(file, indent); +} + +void CSauceDispensor::load(SimpleFile *file) { + file->readNumber(); + _string3 = file->readString(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _pos1 = file->readPoint(); + _pos2 = file->readPoint(); + _field104 = file->readNumber(); + _field108 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sauce_dispensor.h b/engines/titanic/game/sauce_dispensor.h new file mode 100644 index 0000000000..aa177050d5 --- /dev/null +++ b/engines/titanic/game/sauce_dispensor.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SAUCE_DISPENSOR_H +#define TITANIC_SAUCE_DISPENSOR_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CSauceDispensor : public CBackground { +public: + CString _string3; + int _fieldEC; + int _fieldF0; + Point _pos1; + Point _pos2; + int _field104; + int _field108; +public: + CLASSDEF; + CSauceDispensor(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SAUCE_DISPENSOR_H */ diff --git a/engines/titanic/game/search_point.cpp b/engines/titanic/game/search_point.cpp new file mode 100644 index 0000000000..f60a3132b7 --- /dev/null +++ b/engines/titanic/game/search_point.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/search_point.h" + +namespace Titanic { + +void CSearchPoint::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CSearchPoint::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/search_point.h b/engines/titanic/game/search_point.h new file mode 100644 index 0000000000..3c5639b104 --- /dev/null +++ b/engines/titanic/game/search_point.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SEARCH_POINT_H +#define TITANIC_SEARCH_POINT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CSearchPoint : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CSearchPoint() : CGameObject(), _value(2) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SEARCH_POINT_H */ diff --git a/engines/titanic/game/season_background.cpp b/engines/titanic/game/season_background.cpp new file mode 100644 index 0000000000..1c63f3d892 --- /dev/null +++ b/engines/titanic/game/season_background.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/season_background.h" + +namespace Titanic { + +CSeasonBackground::CSeasonBackground() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(46), _fieldEC(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); + + CBackground::save(file, indent); +} + +void CSeasonBackground::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/season_background.h b/engines/titanic/game/season_background.h new file mode 100644 index 0000000000..f0fd2cdc63 --- /dev/null +++ b/engines/titanic/game/season_background.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SEASON_BACKGROUND_H +#define TITANIC_SEASON_BACKGROUND_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CSeasonBackground : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; +public: + CLASSDEF; + CSeasonBackground(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SEASON_BACKGROUND_H */ diff --git a/engines/titanic/game/season_barrel.cpp b/engines/titanic/game/season_barrel.cpp new file mode 100644 index 0000000000..9594396885 --- /dev/null +++ b/engines/titanic/game/season_barrel.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/season_barrel.h" + +namespace Titanic { + +void CSeasonBarrel::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + + CBackground::save(file, indent); +} + +void CSeasonBarrel::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/season_barrel.h b/engines/titanic/game/season_barrel.h new file mode 100644 index 0000000000..f77864599d --- /dev/null +++ b/engines/titanic/game/season_barrel.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SEASON_BARREL_H +#define TITANIC_SEASON_BARREL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CSeasonBarrel : public CBackground { +public: + int _fieldE0; + int _fieldE4; +public: + CLASSDEF; + CSeasonBarrel() : CBackground(), _fieldE0(0), _fieldE4(7) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SEASON_BARREL_H */ diff --git a/engines/titanic/game/seasonal_adjustment.cpp b/engines/titanic/game/seasonal_adjustment.cpp new file mode 100644 index 0000000000..33a0ae89c5 --- /dev/null +++ b/engines/titanic/game/seasonal_adjustment.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/seasonal_adjustment.h" + +namespace Titanic { + +void CSeasonalAdjustment::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + + CBackground::save(file, indent); +} + +void CSeasonalAdjustment::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/seasonal_adjustment.h b/engines/titanic/game/seasonal_adjustment.h new file mode 100644 index 0000000000..39132d614d --- /dev/null +++ b/engines/titanic/game/seasonal_adjustment.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SEASONAL_ADJUSTMENT_H +#define TITANIC_SEASONAL_ADJUSTMENT_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CSeasonalAdjustment : public CBackground { +public: + int _fieldE0; + int _fieldE4; +public: + CLASSDEF; + CSeasonalAdjustment() : CBackground(), _fieldE0(0), _fieldE4(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SEASONAL_ADJUSTMENT_H */ diff --git a/engines/titanic/game/service_elevator_window.cpp b/engines/titanic/game/service_elevator_window.cpp new file mode 100644 index 0000000000..95b2735b37 --- /dev/null +++ b/engines/titanic/game/service_elevator_window.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/service_elevator_window.h" + +namespace Titanic { + +CServiceElevatorWindow::CServiceElevatorWindow() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0) { +} + +void CServiceElevatorWindow::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); + + CBackground::save(file, indent); +} + +void CServiceElevatorWindow::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/service_elevator_window.h b/engines/titanic/game/service_elevator_window.h new file mode 100644 index 0000000000..4233b8405a --- /dev/null +++ b/engines/titanic/game/service_elevator_window.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SERVICE_ELEVATOR_WINDOW_H +#define TITANIC_SERVICE_ELEVATOR_WINDOW_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CServiceElevatorWindow : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; +public: + CLASSDEF; + CServiceElevatorWindow(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SERVICE_ELEVATOR_WINDOW_H */ diff --git a/engines/titanic/game/sgt/armchair.cpp b/engines/titanic/game/sgt/armchair.cpp new file mode 100644 index 0000000000..f547c3ef9a --- /dev/null +++ b/engines/titanic/game/sgt/armchair.cpp @@ -0,0 +1,87 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/armchair.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CArmchair, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + +void CArmchair::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CArmchair::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +bool CArmchair::TurnOn(CTurnOn *msg) { + if (_statics->_v8 == "Closed" && _statics->_v12 == "Closed") { + CVisibleMsg visibleMsg(false); + visibleMsg.execute("Deskchair"); + + if (_statics->_v9 == "Open") { + CActMsg actMsg("Squash"); + actMsg.execute("Deskchair"); + _startFrame = 22; + _endFrame = 31; + } else { + _startFrame = 0; + _endFrame = 10; + } + + playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); + playSound("b#0.wav"); + _statics->_v8 = "Open"; + _fieldE0 = 0; + } + + return true; +} + +bool CArmchair::TurnOff(CTurnOff *msg) { + if (_statics->_v8 == "Open") { + _statics->_v8 = "Closed"; + _startFrame = 11; + _endFrame = 21; + _fieldE0 = 1; + playMovie(11, 21, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playSound("b#0.wav"); + } + + return true; +} + +bool CArmchair::MovieEndMsg(CMovieEndMsg *msg) { + if (_statics->_v8 == "Closed") + loadFrame(0); + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/armchair.h b/engines/titanic/game/sgt/armchair.h new file mode 100644 index 0000000000..169b9b4aa0 --- /dev/null +++ b/engines/titanic/game/sgt/armchair.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ARMCHAIR_H +#define TITANIC_ARMCHAIR_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CArmchair : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ARMCHAIR_H */ diff --git a/engines/titanic/game/sgt/basin.cpp b/engines/titanic/game/sgt/basin.cpp new file mode 100644 index 0000000000..1eb1d161c9 --- /dev/null +++ b/engines/titanic/game/sgt/basin.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/basin.h" + +namespace Titanic { + +void CBasin::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CBasin::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/basin.h b/engines/titanic/game/sgt/basin.h new file mode 100644 index 0000000000..e4a36eb841 --- /dev/null +++ b/engines/titanic/game/sgt/basin.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BASIN_H +#define TITANIC_BASIN_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CBasin : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BASIN_H */ diff --git a/engines/titanic/game/sgt/bedfoot.cpp b/engines/titanic/game/sgt/bedfoot.cpp new file mode 100644 index 0000000000..18ea07aca0 --- /dev/null +++ b/engines/titanic/game/sgt/bedfoot.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/bedfoot.h" + +namespace Titanic { + +void CBedfoot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CBedfoot::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/bedfoot.h b/engines/titanic/game/sgt/bedfoot.h new file mode 100644 index 0000000000..df3db42d6d --- /dev/null +++ b/engines/titanic/game/sgt/bedfoot.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BEDFOOT_H +#define TITANIC_BEDFOOT_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CBedfoot : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BEDFOOT_H */ diff --git a/engines/titanic/game/sgt/bedhead.cpp b/engines/titanic/game/sgt/bedhead.cpp new file mode 100644 index 0000000000..fad7272f3a --- /dev/null +++ b/engines/titanic/game/sgt/bedhead.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/bedhead.h" + +namespace Titanic { + +void CBedhead::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CBedhead::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/bedhead.h b/engines/titanic/game/sgt/bedhead.h new file mode 100644 index 0000000000..f1ba31786c --- /dev/null +++ b/engines/titanic/game/sgt/bedhead.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BEDHEAD_H +#define TITANIC_BEDHEAD_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CBedhead : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BEDHEAD_H */ diff --git a/engines/titanic/game/sgt/chest_of_drawers.cpp b/engines/titanic/game/sgt/chest_of_drawers.cpp new file mode 100644 index 0000000000..be62e12c8e --- /dev/null +++ b/engines/titanic/game/sgt/chest_of_drawers.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/chest_of_drawers.h" + +namespace Titanic { + +void CChestOfDrawers::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CChestOfDrawers::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/chest_of_drawers.h b/engines/titanic/game/sgt/chest_of_drawers.h new file mode 100644 index 0000000000..16a1bf8fea --- /dev/null +++ b/engines/titanic/game/sgt/chest_of_drawers.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEST_OF_DRAWERS_H +#define TITANIC_CHEST_OF_DRAWERS_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CChestOfDrawers : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEST_OF_DRAWERS_H */ diff --git a/engines/titanic/game/sgt/desk.cpp b/engines/titanic/game/sgt/desk.cpp new file mode 100644 index 0000000000..4dd0fdab92 --- /dev/null +++ b/engines/titanic/game/sgt/desk.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/desk.h" + +namespace Titanic { + +void CDesk::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CDesk::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/desk.h b/engines/titanic/game/sgt/desk.h new file mode 100644 index 0000000000..77b5fa17af --- /dev/null +++ b/engines/titanic/game/sgt/desk.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DESK_H +#define TITANIC_DESK_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CDesk : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DESK_H */ diff --git a/engines/titanic/game/sgt/deskchair.cpp b/engines/titanic/game/sgt/deskchair.cpp new file mode 100644 index 0000000000..a4a2badeb0 --- /dev/null +++ b/engines/titanic/game/sgt/deskchair.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/deskchair.h" + +namespace Titanic { + +void CDeskchair::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CDeskchair::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/deskchair.h b/engines/titanic/game/sgt/deskchair.h new file mode 100644 index 0000000000..5181b650d2 --- /dev/null +++ b/engines/titanic/game/sgt/deskchair.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DESKCHAIR_H +#define TITANIC_DESKCHAIR_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CDeskchair : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DESKCHAIR_H */ diff --git a/engines/titanic/game/sgt/drawer.cpp b/engines/titanic/game/sgt/drawer.cpp new file mode 100644 index 0000000000..03aa1b5358 --- /dev/null +++ b/engines/titanic/game/sgt/drawer.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/drawer.h" + +namespace Titanic { + +CDrawer::CDrawer() : CSGTStateRoom(), _fieldF4(0) { +} + +void CDrawer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldF4, indent); + CSGTStateRoom::save(file, indent); +} + +void CDrawer::load(SimpleFile *file) { + file->readNumber(); + _fieldF4 = file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/drawer.h b/engines/titanic/game/sgt/drawer.h new file mode 100644 index 0000000000..c079be389f --- /dev/null +++ b/engines/titanic/game/sgt/drawer.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DRAWER_H +#define TITANIC_DRAWER_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CDrawer : public CSGTStateRoom { +private: + int _fieldF4; +public: + CLASSDEF; + CDrawer(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DRAWER_H */ diff --git a/engines/titanic/game/sgt/sgt_doors.cpp b/engines/titanic/game/sgt/sgt_doors.cpp new file mode 100644 index 0000000000..516b0f1351 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_doors.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_doors.h" + +namespace Titanic { + +void CSGTDoors::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CSGTDoors::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_doors.h b/engines/titanic/game/sgt/sgt_doors.h new file mode 100644 index 0000000000..4b4f4a3153 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_doors.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_DOORS_H +#define TITANIC_SGT_DOORS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CSGTDoors : public CGameObject { +public: + int _value1, _value2; +public: + CLASSDEF; + CSGTDoors() : CGameObject(), _value1(0), _value2(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_DOORS_H */ diff --git a/engines/titanic/game/sgt/sgt_nav.cpp b/engines/titanic/game/sgt/sgt_nav.cpp new file mode 100644 index 0000000000..f98e486fd0 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_nav.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_nav.h" + +namespace Titanic { + +void SGTNav::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void SGTNav::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_nav.h b/engines/titanic/game/sgt/sgt_nav.h new file mode 100644 index 0000000000..40fdc4eff1 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_nav.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_NAV_H +#define TITANIC_SGT_NAV_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class SGTNav : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_NAV_H */ diff --git a/engines/titanic/game/sgt/sgt_navigation.cpp b/engines/titanic/game/sgt/sgt_navigation.cpp new file mode 100644 index 0000000000..d0c308457c --- /dev/null +++ b/engines/titanic/game/sgt/sgt_navigation.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_navigation.h" + +namespace Titanic { + +CSGTNavigationStatics *CSGTNavigation::_statics; + +void CSGTNavigation::init() { + _statics = new CSGTNavigationStatics(); +} + +void CSGTNavigation::deinit() { + delete _statics; +} + +void CSGTNavigation::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_statics->_v1, indent); + file->writeQuotedLine(_statics->_v2, indent); + file->writeQuotedLine(_statics->_v3, indent); + + CGameObject::save(file, indent); +} + +void CSGTNavigation::load(SimpleFile *file) { + file->readNumber(); + _statics->_v1 = file->readNumber(); + _statics->_v2 = file->readString(); + _statics->_v3 = file->readString(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_navigation.h b/engines/titanic/game/sgt/sgt_navigation.h new file mode 100644 index 0000000000..6d24fe6761 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_navigation.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_NAVIGATION_H +#define TITANIC_SGT_NAVIGATION_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +struct CSGTNavigationStatics { + int _v1; + CString _v2; + CString _v3; +}; + +class CSGTNavigation : public CGameObject { +private: + static CSGTNavigationStatics *_statics; +public: + CLASSDEF; + static void init(); + static void deinit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_NAVIGATION_H */ diff --git a/engines/titanic/game/sgt/sgt_restaurant_doors.cpp b/engines/titanic/game/sgt/sgt_restaurant_doors.cpp new file mode 100644 index 0000000000..74a71e75b2 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_restaurant_doors.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_restaurant_doors.h" + +namespace Titanic { + +void CSGTRestaurantDoors::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + CGameObject::save(file, indent); +} + +void CSGTRestaurantDoors::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_restaurant_doors.h b/engines/titanic/game/sgt/sgt_restaurant_doors.h new file mode 100644 index 0000000000..2a10d8f059 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_restaurant_doors.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_RESTAURANT_DOORS_H +#define TITANIC_SGT_RESTAURANT_DOORS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CSGTRestaurantDoors : public CGameObject { +private: + int _fieldBC; +public: + CLASSDEF; + CSGTRestaurantDoors() : CGameObject(), _fieldBC(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_RESTAURANT_DOORS_H */ diff --git a/engines/titanic/game/sgt/sgt_state_control.cpp b/engines/titanic/game/sgt/sgt_state_control.cpp new file mode 100644 index 0000000000..07c1f5efc0 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_state_control.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_state_control.h" + +namespace Titanic { + +void CSGTStateControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + CBackground::save(file, indent); +} + +void CSGTStateControl::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_state_control.h b/engines/titanic/game/sgt/sgt_state_control.h new file mode 100644 index 0000000000..49fd5113cd --- /dev/null +++ b/engines/titanic/game/sgt/sgt_state_control.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_STATE_CONTROL_H +#define TITANIC_SGT_STATE_CONTROL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CSGTStateControl : public CBackground { +private: + int _fieldE0; +public: + CLASSDEF; + CSGTStateControl() : CBackground(), _fieldE0(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_STATE_CONTROL_H */ diff --git a/engines/titanic/game/sgt/sgt_state_room.cpp b/engines/titanic/game/sgt/sgt_state_room.cpp new file mode 100644 index 0000000000..55f08de8b4 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_state_room.cpp @@ -0,0 +1,102 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CSGTStateRoom, CBackground) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +CSGTStateRoomStatics *CSGTStateRoom::_statics; + +void CSGTStateRoom::init() { + _statics = new CSGTStateRoomStatics(); +} + +void CSGTStateRoom::deinit() { + delete _statics; +} + +CSGTStateRoom::CSGTStateRoom() : CBackground(), _fieldE0(1), + _fieldE4(1), _fieldE8(0), _fieldEC(1), _fieldF0(1) { +} + +void CSGTStateRoom::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_statics->_v1, indent); + file->writeQuotedLine(_statics->_v2, indent); + file->writeQuotedLine(_statics->_v3, indent); + file->writeQuotedLine(_statics->_v4, indent); + file->writeQuotedLine(_statics->_v5, indent); + file->writeQuotedLine(_statics->_v6, indent); + file->writeQuotedLine(_statics->_v7, indent); + file->writeQuotedLine(_statics->_v8, indent); + file->writeQuotedLine(_statics->_v9, indent); + file->writeQuotedLine(_statics->_v10, indent); + file->writeQuotedLine(_statics->_v11, indent); + file->writeQuotedLine(_statics->_v12, indent); + + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_statics->_v13, indent); + file->writeNumberLine(_statics->_v14, indent); + file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_fieldF0, indent); + + CBackground::save(file, indent); +} + +void CSGTStateRoom::load(SimpleFile *file) { + file->readNumber(); + _statics->_v1 = file->readString(); + _statics->_v2 = file->readString(); + _statics->_v3 = file->readString(); + _statics->_v4 = file->readString(); + _statics->_v5 = file->readString(); + _statics->_v6 = file->readString(); + _statics->_v7 = file->readString(); + _statics->_v8 = file->readString(); + _statics->_v9 = file->readString(); + _statics->_v10 = file->readString(); + _statics->_v11 = file->readString(); + _statics->_v12 = file->readString(); + + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _statics->_v13 = file->readNumber(); + _statics->_v14 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + + CBackground::load(file); +} + +bool CSGTStateRoom::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CSGTStateRoom::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_state_room.h b/engines/titanic/game/sgt/sgt_state_room.h new file mode 100644 index 0000000000..d9ffdb8e9e --- /dev/null +++ b/engines/titanic/game/sgt/sgt_state_room.h @@ -0,0 +1,78 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_STATE_ROOM_H +#define TITANIC_SGT_STATE_ROOM_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +struct CSGTStateRoomStatics { + CString _v1; + CString _v2; + CString _v3; + CString _v4; + CString _v5; + CString _v6; + CString _v7; + CString _v8; + CString _v9; + CString _v10; + CString _v11; + CString _v12; + int _v13; + int _v14; +}; + +class CSGTStateRoom : public CBackground { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); +protected: + static CSGTStateRoomStatics *_statics; +protected: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; +public: + CLASSDEF; + CSGTStateRoom(); + static void init(); + static void deinit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_STATE_ROOM_H */ diff --git a/engines/titanic/game/sgt/sgt_tv.cpp b/engines/titanic/game/sgt/sgt_tv.cpp new file mode 100644 index 0000000000..ae4c59e2f9 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_tv.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_tv.h" + +namespace Titanic { + +void CSGTTV::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CSGTTV::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_tv.h b/engines/titanic/game/sgt/sgt_tv.h new file mode 100644 index 0000000000..90fed90efe --- /dev/null +++ b/engines/titanic/game/sgt/sgt_tv.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_TV_H +#define TITANIC_SGT_TV_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CSGTTV : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_TV_H */ diff --git a/engines/titanic/game/sgt/sgt_upper_doors_sound.cpp b/engines/titanic/game/sgt/sgt_upper_doors_sound.cpp new file mode 100644 index 0000000000..ed37b0a5c7 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_upper_doors_sound.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/sgt_upper_doors_sound.h" + +namespace Titanic { + +CSGTUpperDoorsSound::CSGTUpperDoorsSound() { + _string2 = "b#53.wav"; +} + +void CSGTUpperDoorsSound::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string2, indent); + + CClickResponder::save(file, indent); +} + +void CSGTUpperDoorsSound::load(SimpleFile *file) { + file->readNumber(); + _string2 = file->readString(); + + CClickResponder::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_upper_doors_sound.h b/engines/titanic/game/sgt/sgt_upper_doors_sound.h new file mode 100644 index 0000000000..fc8c6c2bf1 --- /dev/null +++ b/engines/titanic/game/sgt/sgt_upper_doors_sound.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_UPPER_DOORS_SOUND_H +#define TITANIC_SGT_UPPER_DOORS_SOUND_H + +#include "titanic/core/click_responder.h" + +namespace Titanic { + +class CSGTUpperDoorsSound : public CClickResponder { +public: + CLASSDEF; + CSGTUpperDoorsSound(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_UPPER_DOORS_SOUND_H */ diff --git a/engines/titanic/game/sgt/toilet.cpp b/engines/titanic/game/sgt/toilet.cpp new file mode 100644 index 0000000000..799abd6c76 --- /dev/null +++ b/engines/titanic/game/sgt/toilet.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/toilet.h" + +namespace Titanic { + +void CToilet::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CToilet::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/toilet.h b/engines/titanic/game/sgt/toilet.h new file mode 100644 index 0000000000..d87531ad7a --- /dev/null +++ b/engines/titanic/game/sgt/toilet.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TOILET_H +#define TITANIC_TOILET_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CToilet : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TOILET_H */ diff --git a/engines/titanic/game/sgt/vase.cpp b/engines/titanic/game/sgt/vase.cpp new file mode 100644 index 0000000000..3e04b5db9e --- /dev/null +++ b/engines/titanic/game/sgt/vase.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/vase.h" + +namespace Titanic { + +void CVase::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CVase::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/vase.h b/engines/titanic/game/sgt/vase.h new file mode 100644 index 0000000000..8aa35acdf5 --- /dev/null +++ b/engines/titanic/game/sgt/vase.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_VASE_H +#define TITANIC_VASE_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CVase : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_VASE_H */ diff --git a/engines/titanic/game/sgt/washstand.cpp b/engines/titanic/game/sgt/washstand.cpp new file mode 100644 index 0000000000..8127a59a59 --- /dev/null +++ b/engines/titanic/game/sgt/washstand.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sgt/washstand.h" + +namespace Titanic { + +void CWashstand::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSGTStateRoom::save(file, indent); +} + +void CWashstand::load(SimpleFile *file) { + file->readNumber(); + CSGTStateRoom::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sgt/washstand.h b/engines/titanic/game/sgt/washstand.h new file mode 100644 index 0000000000..f140b17f49 --- /dev/null +++ b/engines/titanic/game/sgt/washstand.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_WASHSTAND_H +#define TITANIC_WASHSTAND_H + +#include "titanic/game/sgt/sgt_state_room.h" + +namespace Titanic { + +class CWashstand : public CSGTStateRoom { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WASHSTAND_H */ diff --git a/engines/titanic/game/ship_setting.cpp b/engines/titanic/game/ship_setting.cpp new file mode 100644 index 0000000000..462f396501 --- /dev/null +++ b/engines/titanic/game/ship_setting.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/ship_setting.h" + +namespace Titanic { + +CShipSetting::CShipSetting() : CBackground(), + _string4("NULL"), _string5("NULL") { +} + +void CShipSetting::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string3, indent); + file->writePoint(_pos1, indent); + file->writeQuotedLine(_string4, indent); + file->writeQuotedLine(_string5, indent); + + CBackground::save(file, indent); +} + +void CShipSetting::load(SimpleFile *file) { + file->readNumber(); + _string3 = file->readString(); + _pos1 = file->readPoint(); + _string4 = file->readString(); + _string5 = file->readString(); + + CBackground::load(file); +} + +bool CShipSetting::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CShipSetting::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/ship_setting.h b/engines/titanic/game/ship_setting.h new file mode 100644 index 0000000000..4fcc10a424 --- /dev/null +++ b/engines/titanic/game/ship_setting.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SHIP_SETTING_H +#define TITANIC_SHIP_SETTING_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CShipSetting : public CBackground { + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + CString _string3; + Point _pos1; + CString _string4; + CString _string5; +public: + CLASSDEF; + CShipSetting(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SHIP_SETTING_H */ diff --git a/engines/titanic/game/ship_setting_button.cpp b/engines/titanic/game/ship_setting_button.cpp new file mode 100644 index 0000000000..7dc2cabac0 --- /dev/null +++ b/engines/titanic/game/ship_setting_button.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/ship_setting_button.h" + +namespace Titanic { + +CShipSettingButton::CShipSettingButton() : CGameObject(), _fieldC8(0), _fieldCC(0) { +} + +void CShipSettingButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + + CGameObject::save(file, indent); +} + +void CShipSettingButton::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/ship_setting_button.h b/engines/titanic/game/ship_setting_button.h new file mode 100644 index 0000000000..e152e8e2c3 --- /dev/null +++ b/engines/titanic/game/ship_setting_button.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SHIP_SETTING_BUTTON_H +#define TITANIC_SHIP_SETTING_BUTTON_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CShipSettingButton : public CGameObject { +private: + CString _string1; + int _fieldC8; + int _fieldCC; +public: + CLASSDEF; + CShipSettingButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SHIP_SETTING_BUTTON_H */ diff --git a/engines/titanic/game/show_cell_points.cpp b/engines/titanic/game/show_cell_points.cpp new file mode 100644 index 0000000000..7d54401a02 --- /dev/null +++ b/engines/titanic/game/show_cell_points.cpp @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/show_cell_points.h" + +namespace Titanic { + +void CShowCellpoints::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_strValue, indent); + file->writeNumberLine(_numValue, indent); + CGameObject::save(file, indent); +} + +void CShowCellpoints::load(SimpleFile *file) { + file->readNumber(); + _strValue = file->readString(); + _numValue = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/show_cell_points.h b/engines/titanic/game/show_cell_points.h new file mode 100644 index 0000000000..9de2e06dca --- /dev/null +++ b/engines/titanic/game/show_cell_points.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHOW_CELL_POINTS_H +#define SHOW_CELL_POINTS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CShowCellpoints : public CGameObject { +public: + CString _strValue; + int _numValue; +public: + CLASSDEF; + CShowCellpoints() : CGameObject(), _numValue(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* SHOW_CELL_POINTS_H */ diff --git a/engines/titanic/game/speech_dispensor.cpp b/engines/titanic/game/speech_dispensor.cpp new file mode 100644 index 0000000000..f9cc019672 --- /dev/null +++ b/engines/titanic/game/speech_dispensor.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/speech_dispensor.h" + +namespace Titanic { + +void CSpeechDispensor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + + CBackground::save(file, indent); +} + +void CSpeechDispensor::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/speech_dispensor.h b/engines/titanic/game/speech_dispensor.h new file mode 100644 index 0000000000..3b877e8d99 --- /dev/null +++ b/engines/titanic/game/speech_dispensor.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SPEECH_DISPENSOR_H +#define TITANIC_SPEECH_DISPENSOR_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CSpeechDispensor : public CBackground { +private: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; + int _fieldF4; + int _fieldF8; + int _fieldFC; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SPEECH_DISPENSOR_H */ diff --git a/engines/titanic/game/splash_animation.cpp b/engines/titanic/game/splash_animation.cpp new file mode 100644 index 0000000000..2094ec14fa --- /dev/null +++ b/engines/titanic/game/splash_animation.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/splash_animation.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CSplashAnimation, CGameObject); + +void CSplashAnimation::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CSplashAnimation::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/splash_animation.h b/engines/titanic/game/splash_animation.h new file mode 100644 index 0000000000..11715b4d73 --- /dev/null +++ b/engines/titanic/game/splash_animation.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SPLASH_ANIMATION_H +#define TITANIC_SPLASH_ANIMATION_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CSplashAnimation : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SPLASH_ANIMATION_H */ diff --git a/engines/titanic/game/starling_puret.cpp b/engines/titanic/game/starling_puret.cpp new file mode 100644 index 0000000000..359ad774df --- /dev/null +++ b/engines/titanic/game/starling_puret.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/starling_puret.h" + +namespace Titanic { + +void CStarlingPuret::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CStarlingPuret::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/starling_puret.h b/engines/titanic/game/starling_puret.h new file mode 100644 index 0000000000..fcd3319958 --- /dev/null +++ b/engines/titanic/game/starling_puret.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STARLING_PURET_H +#define TITANIC_STARLING_PURET_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CStarlingPuret : public CGameObject { +private: + int _value; +public: + CLASSDEF; + CStarlingPuret() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STARLING_PURET_H */ diff --git a/engines/titanic/game/start_action.cpp b/engines/titanic/game/start_action.cpp new file mode 100644 index 0000000000..ab356ea1f4 --- /dev/null +++ b/engines/titanic/game/start_action.cpp @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/start_action.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CStartAction, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + +CStartAction::CStartAction() : CBackground() { +} + +void CStartAction::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_msgTarget, indent); + file->writeQuotedLine(_msgAction, indent); + + CBackground::save(file, indent); +} + +void CStartAction::load(SimpleFile *file) { + file->readNumber(); + _msgTarget = file->readString(); + _msgAction = file->readString(); + + CBackground::load(file); +} + +bool CStartAction::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + // Dispatch the desired action to the desired target + CActMsg actMsg(_msgAction); + actMsg.execute(_msgTarget); + + return true; +} + +bool CStartAction::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/start_action.h b/engines/titanic/game/start_action.h new file mode 100644 index 0000000000..60381bad2f --- /dev/null +++ b/engines/titanic/game/start_action.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_START_ACTION_H +#define TITANIC_START_ACTION_H + +#include "titanic/core/background.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CStartAction : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); +protected: + CString _msgTarget; + CString _msgAction; +public: + CLASSDEF; + CStartAction(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_START_ACTION_H */ diff --git a/engines/titanic/game/stop_phonograph_button.cpp b/engines/titanic/game/stop_phonograph_button.cpp new file mode 100644 index 0000000000..d18f4713ac --- /dev/null +++ b/engines/titanic/game/stop_phonograph_button.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/stop_phonograph_button.h" + +namespace Titanic { + +void CStopPhonographButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBackground::save(file, indent); +} + +void CStopPhonographButton::load(SimpleFile *file) { + file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/stop_phonograph_button.h b/engines/titanic/game/stop_phonograph_button.h new file mode 100644 index 0000000000..b469375e20 --- /dev/null +++ b/engines/titanic/game/stop_phonograph_button.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STOP_PHONOGRAPH_BUTTON_H +#define TITANIC_STOP_PHONOGRAPH_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CStopPhonographButton : public CBackground { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STOP_PHONOGRAPH_BUTTON_H */ diff --git a/engines/titanic/game/sub_glass.cpp b/engines/titanic/game/sub_glass.cpp new file mode 100644 index 0000000000..f1349f06ea --- /dev/null +++ b/engines/titanic/game/sub_glass.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sub_glass.h" + +namespace Titanic { + +CSUBGlass::CSUBGlass() : _fieldBC(0), _fieldC0(0), _fieldC4(1), _fieldC8(0) { +} + +void CSUBGlass::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeQuotedLine(_string, indent); + + CGameObject::save(file, indent); +} + +void CSUBGlass::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + _string = file->readString(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sub_glass.h b/engines/titanic/game/sub_glass.h new file mode 100644 index 0000000000..aab5c8400e --- /dev/null +++ b/engines/titanic/game/sub_glass.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SUB_GLASS_H +#define TITANIC_SUB_GLASS_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CSUBGlass : public CGameObject { +private: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; + CString _string; +public: + CLASSDEF; + CSUBGlass(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ROOM_ITEM_H */ diff --git a/engines/titanic/game/sub_wrapper.cpp b/engines/titanic/game/sub_wrapper.cpp new file mode 100644 index 0000000000..dcc489316b --- /dev/null +++ b/engines/titanic/game/sub_wrapper.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sub_wrapper.h" + +namespace Titanic { + +void CSUBWrapper::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CSUBWrapper::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sub_wrapper.h b/engines/titanic/game/sub_wrapper.h new file mode 100644 index 0000000000..81f8fdc941 --- /dev/null +++ b/engines/titanic/game/sub_wrapper.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SUB_WRAPPER_H +#define TITANIC_SUB_WRAPPER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CSUBWrapper : public CGameObject { +public: + int _value; +public: + CLASSDEF; + CSUBWrapper() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SUB_WRAPPER_H */ diff --git a/engines/titanic/game/sweet_bowl.cpp b/engines/titanic/game/sweet_bowl.cpp new file mode 100644 index 0000000000..e14f900e77 --- /dev/null +++ b/engines/titanic/game/sweet_bowl.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/sweet_bowl.h" + +namespace Titanic { + +void CSweetBowl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CSweetBowl::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/sweet_bowl.h b/engines/titanic/game/sweet_bowl.h new file mode 100644 index 0000000000..cf3d0023a4 --- /dev/null +++ b/engines/titanic/game/sweet_bowl.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SWEET_BOWL_H +#define TITANIC_SWEET_BOWL_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CSweetBowl : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CREDITS_H */ diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp new file mode 100644 index 0000000000..af6bdb8c03 --- /dev/null +++ b/engines/titanic/game/television.cpp @@ -0,0 +1,291 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/titanic.h" +#include "titanic/game/television.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/game/get_lift_eye2.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CTelevision, CGameObject) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(PETUpMsg) + ON_MESSAGE(PETDownMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(PETActivateMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(ShipSettingMsg) + ON_MESSAGE(TurnOff) + ON_MESSAGE(TurnOn) + ON_MESSAGE(LightsMsg) +END_MESSAGE_MAP() + +int CTelevision::_v1; +bool CTelevision::_turnOn; +int CTelevision::_v3; +int CTelevision::_v4; +int CTelevision::_v5; +int CTelevision::_v6; + +CTelevision::CTelevision() : CBackground(), _fieldE0(1), + _fieldE4(7), _isOn(false), _fieldEC(0), _soundHandle(0) { +} + +void CTelevision::init() { + _v1 = 531; + _turnOn = true; + _v3 = 0; + _v4 = 27; + _v5 = 1; + _v6 = 1; +} + +void CTelevision::deinit() { +} + +void CTelevision::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_turnOn, indent); + file->writeNumberLine(_isOn, indent); + file->writeNumberLine(_v3, indent); + file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_v4, indent); + file->writeNumberLine(_soundHandle, indent); + file->writeNumberLine(_v5, indent); + file->writeNumberLine(_v6, indent); + + CBackground::save(file, indent); +} + +void CTelevision::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _v1 = file->readNumber(); + _fieldE4 = file->readNumber(); + _turnOn = file->readNumber() != 0; + _isOn = file->readNumber() != 0; + _v3 = file->readNumber(); + _fieldEC = file->readNumber(); + _v4 = file->readNumber(); + _soundHandle = file->readNumber(); + _v5 = file->readNumber(); + _v6 = file->readNumber(); + + CBackground::load(file); +} + +bool CTelevision::LeaveViewMsg(CLeaveViewMsg *msg) { + petClear(); + if (_isOn) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, 0); + + loadFrame(622); + stopMovie(); + setVisible(0); + _isOn = false; + + if (compareRoomNameTo("CSGState")) { + CVisibleMsg visibleMsg(true); + visibleMsg.execute("Tellypic"); + } + } + + return true; +} + +bool CTelevision::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + if (msg->_season.compareTo("Autumn")) { + _v1 = 545; + _v3 = 0; + } else if (msg->_season.compareTo("Winter")) { + _v1 = 503; + _v3 = 0; + } else if (msg->_season.compareTo("Spring")) { + _v1 = 517; + _v3 = 0; + } else if (msg->_season.compareTo("Winter")) { + _v1 = 531; + _v3 = 0; + } + + return true; +} + +bool CTelevision::EnterViewMsg(CEnterViewMsg *msg) { + petSetArea(PET_REMOTE); + petHighlightGlyph(GLYPH_TELEVISION_CONTROL); + petSetRemoteTarget(); + setVisible(0); + _fieldE0 = 1; + + return true; +} + +static const int START_FRAMES[9] = { 0, 0, 56, 112, 168, 224, 280, 336, 392 }; +static const int END_FRAMES[8] = { 0, 55, 111, 167, 223, 279, 335, 391 }; + +bool CTelevision::PETUpMsg(CPETUpMsg *msg) { + if (msg->_name == "Television" && _isOn) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, 0); + + _fieldE0 = _fieldE0 % _fieldE4 + 1; + stopMovie(); + playMovie(START_FRAMES[_fieldE0], END_FRAMES[_fieldE0], 4); + } + + return true; +} + +bool CTelevision::PETDownMsg(CPETDownMsg *msg) { + if (msg->_name == "Television" && _isOn) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, 0); + if (--_fieldE0 < 1) + _fieldE0 += _fieldE4; + + _fieldE0 = _fieldE0 % _fieldE4 + 1; + stopMovie(); + playMovie(START_FRAMES[_fieldE0], END_FRAMES[_fieldE0], 4); + } + + return true; +} + +bool CTelevision::StatusChangeMsg(CStatusChangeMsg *msg) { + if (_isOn) { + stopMovie(); + playMovie(0); + } + + return true; +} + +bool CTelevision::ActMsg(CActMsg *msg) { + if (msg->_action == "TurnTVOnOff") { + _isOn = !_isOn; + if (_isOn) { + setVisible(true); + CStatusChangeMsg changeMsg; + changeMsg.execute(this); + } else { + setVisible(_isOn); + stopMovie(); + } + } + + return true; +} + +bool CTelevision::PETActivateMsg(CPETActivateMsg *msg) { + if (msg->_name == "Television") { + CVisibleMsg visibleMsg(_isOn); + _isOn = !_isOn; + + if (_isOn) { + setVisible(true); + playMovie(0, 55, 0); + _fieldE0 = 1; + } else { + stopMovie(); + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, 0); + + setVisible(false); + } + + if (compareRoomNameTo("SGTState")) + visibleMsg.execute("Tellypic"); + } + + return true; +} + +bool CTelevision::MovieEndMsg(CMovieEndMsg *msg) { + if (g_vm->getRandomNumber(6) == 0) { + CParrotSpeakMsg parrotMsg("Television", ""); + parrotMsg.execute("PerchedParrot"); + } + + if (_fieldE0 == 3 && compareRoomNameTo("SGTState") && !getPassengerClass()) { + playSound("z#47.wav", 100, 0, 0); + _soundHandle = playSound("b#20.wav", 100, 0, 0); + CTreeItem *magazine = getRoot()->findByName("Magazine"); + + if (magazine) { + warning("TODO: CTelevision::MovieEndMsg"); + } + + loadFrame(561); + } else if (_fieldE0 == 2) { + loadFrame(_v1); + } else if (_fieldE0 == 4 && _v5) { + if (_turnOn) + loadFrame(502); + else + warning("There is currently nothing available for your viewing pleasure on this channel."); + } else if (_fieldE0 == 5 && *CGetLiftEye2::_v1 != "NULL") { + loadFrame(393 + _v4); + } else { + warning("There is currently nothing available for your viewing pleasure on this channel."); + } + + return true; +} + +bool CTelevision::ShipSettingMsg(CShipSettingMsg *msg) { + _v4 = msg->_value; + return true; +} + +bool CTelevision::TurnOff(CTurnOff *msg) { + _turnOn = false; + return true; +} + +bool CTelevision::TurnOn(CTurnOn *msg) { + _turnOn = true; + return true; +} + +bool CTelevision::LightsMsg(CLightsMsg *msg) { + CPetControl *pet = getPetControl(); + bool flag = false; + + if (pet) + flag = pet->isRoom59706(); + + if (msg->_field8 || !flag) + _turnOn = true; + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/television.h b/engines/titanic/game/television.h new file mode 100644 index 0000000000..6e6d9b23c2 --- /dev/null +++ b/engines/titanic/game/television.h @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TELEVISION_H +#define TITANIC_TELEVISION_H + +#include "titanic/core/background.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CTelevision : public CBackground { + DECLARE_MESSAGE_MAP; + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool PETUpMsg(CPETUpMsg *msg); + bool PETDownMsg(CPETDownMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool ActMsg(CActMsg *msg); + bool PETActivateMsg(CPETActivateMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool ShipSettingMsg(CShipSettingMsg *msg); + bool TurnOff(CTurnOff *msg); + bool TurnOn(CTurnOn *msg); + bool LightsMsg(CLightsMsg *msg); +private: + static int _v1; + static bool _turnOn; + static int _v3; + static int _v4; + static int _v5; + static int _v6; +private: + int _fieldE0; + int _fieldE4; + bool _isOn; + int _fieldEC; + int _soundHandle; +public: + CLASSDEF; + CTelevision(); + static void init(); + static void deinit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TELEVISION_H */ diff --git a/engines/titanic/game/third_class_canal.cpp b/engines/titanic/game/third_class_canal.cpp new file mode 100644 index 0000000000..6b0a101f7b --- /dev/null +++ b/engines/titanic/game/third_class_canal.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/third_class_canal.h" + +namespace Titanic { + +void CThirdClassCanal::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CBackground::save(file, indent); +} + +void CThirdClassCanal::load(SimpleFile *file) { + file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/third_class_canal.h b/engines/titanic/game/third_class_canal.h new file mode 100644 index 0000000000..f6fc471444 --- /dev/null +++ b/engines/titanic/game/third_class_canal.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_THIRD_CLASS_CANAL_H +#define TITANIC_THIRD_CLASS_CANAL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CThirdClassCanal : public CBackground { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_THIRD_CLASS_CANAL_H */ diff --git a/engines/titanic/game/throw_tv_down_well.cpp b/engines/titanic/game/throw_tv_down_well.cpp new file mode 100644 index 0000000000..c8a9fc7c9e --- /dev/null +++ b/engines/titanic/game/throw_tv_down_well.cpp @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/throw_tv_down_well.h" + +namespace Titanic { + +void CThrowTVDownWell::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_strValue, indent); + file->writeNumberLine(_numValue, indent); + CGameObject::save(file, indent); +} + +void CThrowTVDownWell::load(SimpleFile *file) { + file->readNumber(); + _strValue = file->readString(); + _numValue = file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/throw_tv_down_well.h b/engines/titanic/game/throw_tv_down_well.h new file mode 100644 index 0000000000..b6003aa3ef --- /dev/null +++ b/engines/titanic/game/throw_tv_down_well.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_THROW_TV_DOWN_WELL_H +#define TITANIC_THROW_TV_DOWN_WELL_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CThrowTVDownWell : public CGameObject { +public: + CString _strValue; + int _numValue; +public: + CLASSDEF; + CThrowTVDownWell() : CGameObject(), _numValue(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_THROW_TV_DOWN_WELL_H */ diff --git a/engines/titanic/game/titania_still_control.cpp b/engines/titanic/game/titania_still_control.cpp new file mode 100644 index 0000000000..67866ecdcb --- /dev/null +++ b/engines/titanic/game/titania_still_control.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/titania_still_control.h" + +namespace Titanic { + +void CTitaniaStillControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CTitaniaStillControl::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/titania_still_control.h b/engines/titanic/game/titania_still_control.h new file mode 100644 index 0000000000..66c3045187 --- /dev/null +++ b/engines/titanic/game/titania_still_control.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TITANIA_STILL_CONTROL_H +#define TITANIC_TITANIA_STILL_CONTROL_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CTitaniaStillControl : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TITANIA_STILL_CONTROL_H */ diff --git a/engines/titanic/game/tow_parrot_nav.cpp b/engines/titanic/game/tow_parrot_nav.cpp new file mode 100644 index 0000000000..9361808870 --- /dev/null +++ b/engines/titanic/game/tow_parrot_nav.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/tow_parrot_nav.h" + +namespace Titanic { + +void CTOWParrotNav::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CTOWParrotNav::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/tow_parrot_nav.h b/engines/titanic/game/tow_parrot_nav.h new file mode 100644 index 0000000000..17618ff6de --- /dev/null +++ b/engines/titanic/game/tow_parrot_nav.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TOW_PARROT_NAV_H +#define TITANIC_TOW_PARROT_NAV_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CTOWParrotNav : public CGameObject { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TOW_PARROT_NAV_H */ diff --git a/engines/titanic/game/transport/exit_pellerator.cpp b/engines/titanic/game/transport/exit_pellerator.cpp new file mode 100644 index 0000000000..400214a140 --- /dev/null +++ b/engines/titanic/game/transport/exit_pellerator.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include "titanic/game/transport/pellerator.h" + +namespace Titanic { + +int CPellerator::_v1; +int CPellerator::_v2; + +void CPellerator::save(SimpleFile *file, int indent) const { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + + CTransport::save(file, indent); +} + +void CPellerator::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + + CTransport::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/transport/exit_pellerator.h b/engines/titanic/game/transport/exit_pellerator.h new file mode 100644 index 0000000000..53056c7417 --- /dev/null +++ b/engines/titanic/game/transport/exit_pellerator.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef TITANIC_PELLERATOR_H +#define TITANIC_PELLERATOR_H + +#include "titanic/game/transport/transport.h" + +namespace Titanic { + +class CPellerator : public CTransport { +private: + static int _v1; + static int _v2; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PELLERATOR_H */ diff --git a/engines/titanic/game/transport/gondolier.cpp b/engines/titanic/game/transport/gondolier.cpp new file mode 100644 index 0000000000..f731e45bde --- /dev/null +++ b/engines/titanic/game/transport/gondolier.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/transport/gondolier.h" + +namespace Titanic { + +void CGondolier::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CTransport::save(file, indent); +} + +void CGondolier::load(SimpleFile *file) { + file->readNumber(); + CTransport::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/transport/gondolier.h b/engines/titanic/game/transport/gondolier.h new file mode 100644 index 0000000000..ac1617256f --- /dev/null +++ b/engines/titanic/game/transport/gondolier.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GONDOLIER_H +#define TITANIC_GONDOLIER_H + +#include "titanic/game/transport/transport.h" + +namespace Titanic { + +class CGondolier : public CTransport { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GONDOLIER_H */ diff --git a/engines/titanic/game/transport/lift.cpp b/engines/titanic/game/transport/lift.cpp new file mode 100644 index 0000000000..72f832bf76 --- /dev/null +++ b/engines/titanic/game/transport/lift.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/transport/lift.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CLift, CTransport) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +int CLift::_v1; +int CLift::_v2; +int CLift::_v3; +int CLift::_v4; +int CLift::_v5; +int CLift::_v6; + +void CLift::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_v3, indent); + file->writeNumberLine(_v4, indent); + file->writeNumberLine(_v5, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_v6, indent); + + CTransport::save(file, indent); +} + +void CLift::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _v3 = file->readNumber(); + _v4 = file->readNumber(); + _v5 = file->readNumber(); + _fieldF8 = file->readNumber(); + _v6 = file->readNumber(); + + CTransport::load(file); +} + +bool CLift::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CLift::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/transport/lift.h b/engines/titanic/game/transport/lift.h new file mode 100644 index 0000000000..4595f0fec2 --- /dev/null +++ b/engines/titanic/game/transport/lift.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef TITANIC_LIFT_H +#define TITANIC_LIFT_H + +#include "titanic/game/transport/transport.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CLift : public CTransport { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + static int _v1; + static int _v2; + static int _v3; + static int _v4; + static int _v5; + static int _v6; + + int _fieldF8; +public: + CLASSDEF; + CLift() : CTransport(), _fieldF8(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIFT_H */ diff --git a/engines/titanic/game/transport/lift_indicator.cpp b/engines/titanic/game/transport/lift_indicator.cpp new file mode 100644 index 0000000000..582de8ad3b --- /dev/null +++ b/engines/titanic/game/transport/lift_indicator.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/transport/lift_indicator.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CLiftindicator, CLift) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +CLiftindicator::CLiftindicator() : CLift(), + _fieldFC(0), _field108(0), _field10C(0) { +} + +void CLiftindicator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldFC, indent); + file->writePoint(_pos2, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_field10C, indent); + + CLift::save(file, indent); +} + +void CLiftindicator::load(SimpleFile *file) { + file->readNumber(); + _fieldFC = file->readNumber(); + _pos2 = file->readPoint(); + _field108 = file->readNumber(); + _field10C = file->readNumber(); + + CLift::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/transport/lift_indicator.h b/engines/titanic/game/transport/lift_indicator.h new file mode 100644 index 0000000000..945f627417 --- /dev/null +++ b/engines/titanic/game/transport/lift_indicator.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LIFT_INDICATOR_H +#define TITANIC_LIFT_INDICATOR_H + +#include "titanic/game/transport/lift.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CLiftindicator : public CLift { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg) { return true; } +private: + int _fieldFC; + Point _pos2; + int _field108; + int _field10C; +public: + CLASSDEF; + CLiftindicator(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIFT_INDICATOR_H */ diff --git a/engines/titanic/game/transport/pellerator.cpp b/engines/titanic/game/transport/pellerator.cpp new file mode 100644 index 0000000000..e789c20a3d --- /dev/null +++ b/engines/titanic/game/transport/pellerator.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include "titanic/game/transport/pellerator.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPellerator, CTransport) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +int CPellerator::_v1; +int CPellerator::_v2; + +void CPellerator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + + CTransport::save(file, indent); +} + +void CPellerator::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + + CTransport::load(file); +} + +bool CPellerator::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CPellerator::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/transport/pellerator.h b/engines/titanic/game/transport/pellerator.h new file mode 100644 index 0000000000..fa400a49cd --- /dev/null +++ b/engines/titanic/game/transport/pellerator.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef TITANIC_PELLERATOR_H +#define TITANIC_PELLERATOR_H + +#include "titanic/game/transport/transport.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CPellerator : public CTransport { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + static int _v1; + static int _v2; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PELLERATOR_H */ diff --git a/engines/titanic/game/transport/service_elevator.cpp b/engines/titanic/game/transport/service_elevator.cpp new file mode 100644 index 0000000000..1ea8d14e36 --- /dev/null +++ b/engines/titanic/game/transport/service_elevator.cpp @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/transport/service_elevator.h" + +namespace Titanic { + +int CServiceElevator::_v1; +int CServiceElevator::_v2; +int CServiceElevator::_v3; + +CServiceElevator::CServiceElevator() : CTransport(), + _fieldF8(0), _fieldFC(0), _field100(0), _field104(0) { +} + +void CServiceElevator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_v3, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_field100, indent); + file->writeNumberLine(_field104, indent); + + CTransport::save(file, indent); +} + +void CServiceElevator::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _v3 = file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + _field100 = file->readNumber(); + _field104 = file->readNumber(); + + CTransport::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/transport/service_elevator.h b/engines/titanic/game/transport/service_elevator.h new file mode 100644 index 0000000000..b2c135021a --- /dev/null +++ b/engines/titanic/game/transport/service_elevator.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SERVICE_ELEVATOR_H +#define TITANIC_SERVICE_ELEVATOR_H + +#include "titanic/game/transport/transport.h" + +namespace Titanic { + +class CServiceElevator : public CTransport { +private: + static int _v1; + static int _v2; + static int _v3; + + int _fieldF8; + int _fieldFC; + int _field100; + int _field104; +public: + CLASSDEF; + CServiceElevator(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SERVICE_ELEVATOR_H */ diff --git a/engines/titanic/game/transport/transport.cpp b/engines/titanic/game/transport/transport.cpp new file mode 100644 index 0000000000..6fe45c2fc8 --- /dev/null +++ b/engines/titanic/game/transport/transport.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/transport/transport.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CTransport, CMobile); + +CTransport::CTransport() : CMobile(), _string1("*.*.*") { +} + +void CTransport::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + + CMobile::save(file, indent); +} + +void CTransport::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + + CMobile::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/transport/transport.h b/engines/titanic/game/transport/transport.h new file mode 100644 index 0000000000..d87251212a --- /dev/null +++ b/engines/titanic/game/transport/transport.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TRANSPORT_H +#define TITANIC_TRANSPORT_H + +#include "titanic/npcs/mobile.h" + +namespace Titanic { + +class CTransport : public CMobile { + DECLARE_MESSAGE_MAP; +public: + CString _string1; + CString _string2; +public: + CLASSDEF; + CTransport(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TRANSPORT_H */ diff --git a/engines/titanic/game/up_lighter.cpp b/engines/titanic/game/up_lighter.cpp new file mode 100644 index 0000000000..f03b8f37a0 --- /dev/null +++ b/engines/titanic/game/up_lighter.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/up_lighter.h" + +namespace Titanic { + +CUpLighter::CUpLighter() : CDropTarget(), _field118(0), + _field11C(0), _field120(0), _field124(0) { +} + +void CUpLighter::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field118, indent); + file->writeNumberLine(_field11C, indent); + file->writeNumberLine(_field120, indent); + file->writeNumberLine(_field124, indent); + + CDropTarget::save(file, indent); +} + +void CUpLighter::load(SimpleFile *file) { + file->readNumber(); + _field118 = file->readNumber(); + _field11C = file->readNumber(); + _field120 = file->readNumber(); + _field124 = file->readNumber(); + + CDropTarget::load(file); +} + +bool CUpLighter::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CUpLighter::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/up_lighter.h b/engines/titanic/game/up_lighter.h new file mode 100644 index 0000000000..2367e41314 --- /dev/null +++ b/engines/titanic/game/up_lighter.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_UP_LIGHTER_H +#define TITANIC_UP_LIGHTER_H + +#include "titanic/core/drop_target.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CUpLighter : public CDropTarget { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _field118; + int _field11C; + int _field120; + int _field124; +public: + CLASSDEF; + CUpLighter(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_UP_LIGHTER_H */ diff --git a/engines/titanic/game/useless_lever.cpp b/engines/titanic/game/useless_lever.cpp new file mode 100644 index 0000000000..e48ad55a71 --- /dev/null +++ b/engines/titanic/game/useless_lever.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/useless_lever.h" + +namespace Titanic { + +void CUselessLever::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleButton::save(file, indent); +} + +void CUselessLever::load(SimpleFile *file) { + file->readNumber(); + CToggleButton::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/useless_lever.h b/engines/titanic/game/useless_lever.h new file mode 100644 index 0000000000..27397de216 --- /dev/null +++ b/engines/titanic/game/useless_lever.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_USELESS_LEVER_H +#define TITANIC_USELESS_LEVER_H + +#include "titanic/gfx/toggle_button.h" + +namespace Titanic { + +class CUselessLever : public CToggleButton { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_UP_LIGHTER_H */ diff --git a/engines/titanic/game/volume_control.cpp b/engines/titanic/game/volume_control.cpp new file mode 100644 index 0000000000..c6b0e414ae --- /dev/null +++ b/engines/titanic/game/volume_control.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/volume_control.h" + +namespace Titanic { + +CVolumeControl::CVolumeControl() : CGameObject() { +} + +void CVolumeControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_fieldCC, indent); + + CGameObject::save(file, indent); +} + +void CVolumeControl::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _string1 = file->readString(); + _fieldCC = file->readNumber(); + + CGameObject::load(file); +} + +bool CVolumeControl::EnterNodeMsg(CEnterNodeMsg *msg) { + warning("CVolumeControl::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/volume_control.h b/engines/titanic/game/volume_control.h new file mode 100644 index 0000000000..dcc6f63781 --- /dev/null +++ b/engines/titanic/game/volume_control.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_VOLUME_CONTROL_H +#define TITANIC_VOLUME_CONTROL_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CVolumeControl : public CGameObject { + bool EnterNodeMsg(CEnterNodeMsg *msg); +private: + int _fieldBC; + CString _string1; + int _fieldCC; +public: + CLASSDEF; + CVolumeControl(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_VOLUME_CONTROL_H */ diff --git a/engines/titanic/game/wheel_button.cpp b/engines/titanic/game/wheel_button.cpp new file mode 100644 index 0000000000..19c42a8807 --- /dev/null +++ b/engines/titanic/game/wheel_button.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/wheel_button.h" + +namespace Titanic { + +CWheelButton::CWheelButton() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(0) { +} + +void CWheelButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + + CBackground::save(file, indent); +} + +void CWheelButton::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/wheel_button.h b/engines/titanic/game/wheel_button.h new file mode 100644 index 0000000000..cb089a660f --- /dev/null +++ b/engines/titanic/game/wheel_button.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_WHEEL_BUTTON_H +#define TITANIC_WHEEL_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CWheelButton : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; +public: + CLASSDEF; + CWheelButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WHEEL_BUTTON_H */ diff --git a/engines/titanic/game/wheel_hotspot.cpp b/engines/titanic/game/wheel_hotspot.cpp new file mode 100644 index 0000000000..f9af594cd5 --- /dev/null +++ b/engines/titanic/game/wheel_hotspot.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/wheel_hotspot.h" + +namespace Titanic { + +void CWheelHotSpot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + + CBackground::save(file, indent); +} + +void CWheelHotSpot::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/wheel_hotspot.h b/engines/titanic/game/wheel_hotspot.h new file mode 100644 index 0000000000..364fe9a060 --- /dev/null +++ b/engines/titanic/game/wheel_hotspot.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_WHEEL_HOTSPOT_H +#define TITANIC_WHEEL_HOTSPOT_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CWheelHotSpot : public CBackground { +public: + int _fieldE0; + int _fieldE4; +public: + CLASSDEF; + CWheelHotSpot() : CBackground(), _fieldE0(0), _fieldE4(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WHEEL_HOTSPOT_H */ diff --git a/engines/titanic/game/wheel_spin.cpp b/engines/titanic/game/wheel_spin.cpp new file mode 100644 index 0000000000..daa9918e29 --- /dev/null +++ b/engines/titanic/game/wheel_spin.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/wheel_spin.h" + +namespace Titanic { + +void CWheelSpin::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CBackground::save(file, indent); +} + +void CWheelSpin::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/wheel_spin.h b/engines/titanic/game/wheel_spin.h new file mode 100644 index 0000000000..509db1a4bf --- /dev/null +++ b/engines/titanic/game/wheel_spin.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_WHEEL_SPIN_H +#define TITANIC_WHEEL_SPIN_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CWheelSpin : public CBackground { +public: + int _value; +public: + CLASSDEF; + CWheelSpin() : CBackground(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WHEEL_SPIN_H */ diff --git a/engines/titanic/game/wheel_spin_horn.cpp b/engines/titanic/game/wheel_spin_horn.cpp new file mode 100644 index 0000000000..b01cc678df --- /dev/null +++ b/engines/titanic/game/wheel_spin_horn.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game/wheel_spin_horn.h" + +namespace Titanic { + +void CWheelSpinHorn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + + CWheelSpin::save(file, indent); +} + +void CWheelSpinHorn::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + + CWheelSpin::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/wheel_spin_horn.h b/engines/titanic/game/wheel_spin_horn.h new file mode 100644 index 0000000000..21182253b3 --- /dev/null +++ b/engines/titanic/game/wheel_spin_horn.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_WHEEL_SPIN_HORN_H +#define TITANIC_WHEEL_SPIN_HORN_H + +#include "titanic/game/wheel_spin.h" + +namespace Titanic { + +class CWheelSpinHorn : public CWheelSpin { +public: + CString _string1; + CString _string2; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WHEEL_SPIN_HORN_H */ diff --git a/engines/titanic/game_location.cpp b/engines/titanic/game_location.cpp new file mode 100644 index 0000000000..3a1d0c9e48 --- /dev/null +++ b/engines/titanic/game_location.cpp @@ -0,0 +1,115 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game_location.h" +#include "titanic/game_manager.h" +#include "titanic/game_state.h" +#include "titanic/core/game_object.h" +#include "titanic/core/project_item.h" + +namespace Titanic { + +#define STARTING_ROOM 3 +#define STARTING_NODE 1 +#define STARTING_VIEW 4 + +CGameLocation::CGameLocation(CGameState *owner) : _gameState(owner), + _view(nullptr), _roomNumber(STARTING_ROOM), + _nodeNumber(STARTING_NODE), _viewNumber(STARTING_VIEW) { +} + +void CGameLocation::save(SimpleFile *file) const { + file->writeNumber(_roomNumber); + file->writeNumber(_nodeNumber); + file->writeNumber(_viewNumber); +} + +void CGameLocation::load(SimpleFile *file) { + _view = nullptr; + _roomNumber = file->readNumber(); + _nodeNumber = file->readNumber(); + _viewNumber = file->readNumber(); +} + +void CGameLocation::setView(CViewItem *view) { + if (_view) { + for (CTreeItem *treeItem = _view; treeItem; + treeItem = treeItem->scan(_view)) { + CGameObject *obj = dynamic_cast<CGameObject *>(treeItem); + if (obj) + obj->stopMovie(); + } + } + + _view = view; + if (_view) { + _viewNumber = _view->_viewNumber; + _nodeNumber = _view->findNode()->_nodeNumber; + _roomNumber = _view->findRoom()->_roomNumber; + } else { + _viewNumber = _nodeNumber = _roomNumber = -1; + } +} + +CViewItem *CGameLocation::getView() { + if (!_view) { + CGameManager *gm = _gameState->_gameManager; + _view = gm->_project->findView(_roomNumber, _nodeNumber, _viewNumber); + + if (!_view) { + // Fallback if view not found + _view = gm->_project->findView(STARTING_ROOM, + STARTING_NODE, STARTING_VIEW); + + if (!_view) { + // Fallback for the fallback + for (int idx = 0; idx < 99 && !_view; ++idx) { + _view = gm->_project->findView(idx, 1, 1); + } + } + } + } + + if (!_view) { + // Okay seriously, yet another fallback if view not found + _viewNumber = _nodeNumber = _roomNumber = -1; + _view = nullptr; + } else { + _viewNumber = _view->_viewNumber; + _nodeNumber = _view->findNode()->_nodeNumber; + _roomNumber = _view->findRoom()->_roomNumber; + } + + return _view; +} + +CNodeItem *CGameLocation::getNode() { + CViewItem *view = getView(); + return !view ? nullptr : view->findNode(); +} + +CRoomItem *CGameLocation::getRoom() { + CViewItem *view = getView(); + return !view ? nullptr : view->findRoom(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game_location.h b/engines/titanic/game_location.h new file mode 100644 index 0000000000..f145d36340 --- /dev/null +++ b/engines/titanic/game_location.h @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GAME_LOCATION_H +#define TITANIC_GAME_LOCATION_H + +#include "titanic/support/simple_file.h" +#include "titanic/core/node_item.h" +#include "titanic/core/room_item.h" +#include "titanic/core/view_item.h" + +namespace Titanic { + +class CGameState; + +class CGameLocation { +private: + CGameState *_gameState; + CViewItem *_view; + + int _roomNumber; + int _nodeNumber; + int _viewNumber; +public: + CGameLocation(CGameState *owner); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file) const; + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file); + + /** + * Set the current view + */ + void setView(CViewItem *view); + + /** + * Get the current view + */ + CViewItem *getView(); + + /** + * Get the current node + */ + CNodeItem *getNode(); + + /** + * Get the current room + */ + CRoomItem *getRoom(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GAME_LOCATION_H */ diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp new file mode 100644 index 0000000000..9bc9e4d067 --- /dev/null +++ b/engines/titanic/game_manager.cpp @@ -0,0 +1,313 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/titanic.h" +#include "titanic/game_manager.h" +#include "titanic/game_view.h" +#include "titanic/support/screen_manager.h" +#include "titanic/core/project_item.h" +#include "titanic/messages/messages.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +CGameManager::CGameManager(CProjectItem *project, CGameView *gameView, Audio::Mixer *mixer): + _project(project), _gameView(gameView), _trueTalkManager(this), + _inputHandler(this), _inputTranslator(&_inputHandler), + _gameState(this), _sound(this, mixer), _musicRoom(this), + _treeItem(nullptr), _soundMaker(nullptr), _movieRoom(nullptr), + _dragItem(nullptr), _field54(0), _lastDiskTicksCount(0), _tickCount2(0) { + + CTimeEventInfo::_nextId = 0; + _movie = nullptr; + _movieSurface = CScreenManager::_screenManagerPtr->createSurface(600, 340); + _project->setGameManager(this); + g_vm->_filesManager->setGameManager(this); +} + +CGameManager::~CGameManager() { + delete _movie; + delete _movieSurface; + destroyTreeItem(); + + _project->resetGameManager(); +} + +void CGameManager::destroyTreeItem() { + if (_treeItem) { + _treeItem->destroyAll(); + _treeItem = nullptr; + } +} + +void CGameManager::save(SimpleFile *file) { + file->writeNumber(_lastDiskTicksCount); + _gameState.save(file); + _timers.save(file, 0); + _trueTalkManager.save(file); + _sound.save(file); +} + +void CGameManager::load(SimpleFile *file) { + file->readNumber(); + + _gameState.load(file); + _timers.load(file); + _trueTalkManager.load(file); + _sound.load(file); +} + +void CGameManager::preLoad() { + updateDiskTicksCount(); + _timers.destroyContents(); + _soundMaker = nullptr; + + _trueTalkManager.preLoad(); + _sound.preLoad(); +} + +void CGameManager::postLoad(CProjectItem *project) { + if (_gameView) { + _gameView->postLoad(); + + if (!_gameView->_surface) { + CViewItem *view = getView(); + if (view) + _gameView->setView(view); + } + } + + // Signal to anything interested that the game has been loaded + CLoadSuccessMsg msg(_lastDiskTicksCount - _tickCount2); + msg.execute(project, nullptr, MSGFLAG_SCAN); + + // Signal to any registered timers + _timers.postLoad(_lastDiskTicksCount, _project); + + // Signal the true talk manager and sound + _trueTalkManager.postLoad(); + _sound.postLoad(); +} + +void CGameManager::preSave(CProjectItem *project) { + // Generate a message that a save is being done + updateDiskTicksCount(); + CPreSaveMsg msg(_lastDiskTicksCount); + msg.execute(project, nullptr, MSGFLAG_SCAN); + + // Notify sub-objects of the save + _timers.preSave(_lastDiskTicksCount); + _trueTalkManager.preSave(); + _sound.preSave(); +} + +void CGameManager::postSave() { + _timers.postSave(); + _trueTalkManager.postSave(); + _sound.postSave(); +} + +void CGameManager::initBounds() { + _bounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); +} + +void CGameManager::roomTransition(CRoomItem *oldRoom, CRoomItem *newRoom) { + delete _movie; + _movie = nullptr; + + CResourceKey movieKey = (oldRoom == newRoom) ? oldRoom->getTransitionMovieKey() : + oldRoom->getExitMovieKey(); + CString filename = movieKey.exists(); + if (g_vm->_filesManager->fileExists(filename)) { + _movieSurface->freeSurface(); + _movie = g_vm->_movieManager.createMovie(filename, _movieSurface); + } +} + +void CGameManager::playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *newRoom) { + if (oldRoom != newRoom || newRoom != _movieRoom || !_movie) + roomTransition(oldRoom, newRoom); + + if (clip && clip->_startFrame != clip->_endFrame && _movie) { + // Clip details specifying a sub-section of movie to play + Rect tempRect(20, 10, SCREEN_WIDTH - 20, 350); + + lockInputHandler(); + CScreenManager::_screenManagerPtr->_mouseCursor->hide(); + _movie->playClip(tempRect, clip->_startFrame, clip->_endFrame); + CScreenManager::_screenManagerPtr->_mouseCursor->show(); + unlockInputHandler(); + } +} + +void CGameManager::update() { + updateMovies(); + frameMessage(getRoom()); + _timers.update(g_vm->_events->getTicksCount()); + _trueTalkManager.removeCompleted(); + _trueTalkManager.update2(); + CScreenManager::_screenManagerPtr->_mouseCursor->update(); + + CViewItem *view = getView(); + if (view) { + // Expand the game manager's bounds to encompass all the view's items + for (CTreeItem *item = view; item; item = item->scan(view)) { + Rect r = item->getBounds(); + if (!r.isEmpty()) + _bounds.extend(r); + } + + // Also include the PET control in the bounds + if (_project) { + CPetControl *pet = _project->getPetControl(); + if (pet) + _bounds.extend(pet->getBounds()); + } + + // And the text cursor + CScreenManager *screenManager = CScreenManager::_screenManagerPtr; + CTextCursor *textCursor = screenManager->_textCursor; + if (textCursor && textCursor->_active) + _bounds.extend(textCursor->getCursorBounds()); + + // Set the surface bounds + screenManager->setSurfaceBounds(SURFACE_BACKBUFFER, _bounds); + + // Handle redrawing the view + if (!_bounds.isEmpty()) { + _gameView->draw(_bounds); + _bounds = Rect(); + } + + _gameState.checkForViewChange(); + } +} + +void CGameManager::updateMovies() { + // Initial iteration to mark all the movies as not yet handled + for (CMovieList::iterator i = CMovie::_playingMovies->begin(); + i != CMovie::_playingMovies->end(); ++i) + (*i)->_handled = false; + + bool repeatFlag; + do { + repeatFlag = false; + + // Scan for a movie to process + for (CMovieList::iterator i = CMovie::_playingMovies->begin(); + i != CMovie::_playingMovies->end(); ++i) { + CMovie *movie = *i; + if (movie->_handled) + continue; + + CMovieEventList eventsList; + if (!movie->handleEvents(eventsList)) + movie->removeFromPlayingMovies(); + + while (!eventsList.empty()) { + CMovieEvent *movieEvent = eventsList.front(); + + switch (movieEvent->_type) { + case MET_MOVIE_END: { + CMovieEndMsg endMsg(movieEvent->_startFrame, movieEvent->_endFrame); + endMsg.execute(movieEvent->_gameObject); + break; + } + + case MET_FRAME: { + CMovieFrameMsg frameMsg(movieEvent->_initialFrame, 0); + frameMsg.execute(movieEvent->_gameObject); + break; + } + + default: + break; + } + + eventsList.remove(movieEvent); + } + + // Flag the movie as having been handled + movie->_handled = true; + repeatFlag = true; + break; + } + } while (repeatFlag); +} + +void CGameManager::updateDiskTicksCount() { + _lastDiskTicksCount = g_vm->_events->getTicksCount(); +} + +void CGameManager::viewChange() { + delete _movie; + delete _movieSurface; + + _movie = nullptr; + _movieSurface = CScreenManager::_screenManagerPtr->createSurface(600, 340); + _trueTalkManager.clear(); + + for (CTreeItem *treeItem = _project; treeItem; treeItem = treeItem->scan(_project)) + treeItem->viewChange(); + + initBounds(); +} + +void CGameManager::frameMessage(CRoomItem *room) { + if (room) { + // Signal the next frame + CFrameMsg frameMsg(g_vm->_events->getTicksCount()); + frameMsg.execute(room, nullptr, MSGFLAG_SCAN); + + if (!_soundMaker) { + // Check for a sound maker in the room + _soundMaker = dynamic_cast<CBackgroundSoundMaker *>( + _project->findByName("zBackgroundSoundMaker")); + } + + // If there's a sound maker, dispatch the event to it as well + if (_soundMaker) + frameMsg.execute(_soundMaker); + } +} + +void CGameManager::extendBounds(const Rect &r) { + if (_bounds.isEmpty()) + _bounds = r; + else + _bounds.combine(r); +} + +CScreenManager *CGameManager::setScreenManager() const { + return CScreenManager::setCurrent(); +} + +CString CGameManager::getFullViewName() { + CViewItem *view = getView(); + CNodeItem *node = view->findNode(); + CRoomItem *room = node->findRoom(); + + return CString::format("%s.%s.%s", room->getName().c_str(), + node->getName().c_str(), view->getName().c_str()); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h new file mode 100644 index 0000000000..262ea0169b --- /dev/null +++ b/engines/titanic/game_manager.h @@ -0,0 +1,217 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GAME_MANAGER_H +#define TITANIC_GAME_MANAGER_H + +#include "common/scummsys.h" +#include "titanic/game_state.h" +#include "titanic/input_handler.h" +#include "titanic/input_translator.h" +#include "titanic/support/simple_file.h" +#include "titanic/support/time_event_info.h" +#include "titanic/support/video_surface.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/sound/background_sound_maker.h" +#include "titanic/sound/music_room.h" +#include "titanic/sound/sound.h" + +namespace Titanic { + +class CProjectItem; +class CGameView; + +class CGameManager { +private: + CTrueTalkManager _trueTalkManager; + CTimeEventInfoList _timers; + CTreeItem *_treeItem; + CBackgroundSoundMaker *_soundMaker; + CMovie *_movie; + CRoomItem *_movieRoom; + int _field54; + CVideoSurface *_movieSurface; + uint _lastDiskTicksCount; + uint _tickCount2; +private: + /** + * Generates a message for the next game frame + */ + void frameMessage(CRoomItem *room); + + /** + * Handles any ongoing movie playback + */ + void updateMovies(); + + /** + * Handles a room transition + */ + void roomTransition(CRoomItem *oldRoom, CRoomItem *newRoom); +public: + CProjectItem *_project; + CGameView *_gameView; + CGameState _gameState; + Rect _bounds; + CInputHandler _inputHandler; + CInputTranslator _inputTranslator; + CTreeItem *_dragItem; + CMusicRoom _musicRoom; + CSound _sound; +public: + CGameManager(CProjectItem *project, CGameView *gameView, Audio::Mixer *mixer); + ~CGameManager(); + + /** + * Destroys and allocated tree item + */ + void destroyTreeItem(); + + /** + * Save data to a save file + */ + void save(SimpleFile *file); + + /** + * Load data from a save file + */ + void load(SimpleFile *file); + + /** + * Called when a game is about to be loaded + */ + void preLoad(); + + /** + * Called after loading a game has finished + */ + void postLoad(CProjectItem *project); + + /** + * Called when a game is about to be saved + */ + void preSave(CProjectItem *project); + + /** + * Called when a game has finished being saved + */ + void postSave(); + + /** + * Updates the game time when the last disk access started + */ + void updateDiskTicksCount(); + + /** + * Gets the current view + */ + CViewItem *getView() { return _gameState._gameLocation.getView(); } + + /** + * Gets the current room node + */ + CNodeItem *getNode() { return _gameState._gameLocation.getNode(); } + + /** + * Gets the current room + */ + CRoomItem *getRoom() { return _gameState._gameLocation.getRoom(); } + + /** + * Lock the input handler + */ + void lockInputHandler() { _inputHandler.incLockCount(); } + + /** + * Unlock the input handler + */ + void unlockInputHandler() { _inputHandler.decLockCount(); } + + /** + * Set default screen bounds + */ + void initBounds(); + + /** + * Plays a movie clip + */ + void playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *newRoom); + + /** + * Main frame update method for the game + */ + void update(); + + /** + * Called when the view changes + */ + void viewChange(); + + bool test54() const { return !_field54; } + + void inc54() { ++_field54; } + + void dec54() { --_field54; } + + /** + * Extends the bounds of the currently affected game display area + * to include the passed rect + */ + void extendBounds(const Rect &r); + + /** + * Set and return the current screen manager + */ + CScreenManager *setScreenManager() const; + + /** + * Adds a timer + */ + void addTimer(CTimeEventInfo *timer) { _timers.push_back(timer); } + + /** + * Stops a timer + */ + void stopTimer(uint id) { _timers.stop(id); } + + /** + * Flags whether the timer will be persisent across save & loads + */ + void setTimerPersisent(uint id, bool flag) { + _timers.setPersisent(id, flag); + } + + /** + * Return the true talk manager + */ + CTrueTalkManager *getTalkManager() { return &_trueTalkManager; } + + /** + * Return the full Id of the current view in a + * room.node.view tuplet form + */ + CString getFullViewName(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GAME_MANAGER_H */ diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp new file mode 100644 index 0000000000..5628161558 --- /dev/null +++ b/engines/titanic/game_state.cpp @@ -0,0 +1,168 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game_state.h" +#include "titanic/titanic.h" +#include "titanic/game_manager.h" +#include "titanic/support/screen_manager.h" + +namespace Titanic { + +bool CGameStateMovieList::clear() { + for (CGameStateMovieList::iterator i = begin(); i != end(); ) { + CMovieListItem *movieItem = *i; + + if (movieItem->_item->isActive()) { + ++i; + } else { + i = erase(i); + delete movieItem; + } + } + + return !empty(); +} + +/*------------------------------------------------------------------------*/ + +CGameState::CGameState(CGameManager *gameManager) : + _gameManager(gameManager), _gameLocation(this), + _passengerClass(0), _priorClass(0), _mode(GSMODE_NONE), + _field14(0), _petActive(false), _field1C(false), _quitGame(false), + _field24(0), _nodeChangeCtr(0), _nodeEnterTicks(0), _field38(0) { +} + +void CGameState::save(SimpleFile *file) const { + file->writeNumber(_petActive); + file->writeNumber(_passengerClass); + file->writeNumber(_priorClass); + file->writeNumber(_field14); + file->writeNumber(_field24); + file->writeNumber(_field38); + _gameLocation.save(file); + file->writeNumber(_field1C); +} + +void CGameState::load(SimpleFile *file) { + _petActive = file->readNumber() != 0; + _passengerClass = file->readNumber(); + _priorClass = file->readNumber(); + _field14 = file->readNumber(); + _field24 = file->readNumber(); + _field38 = file->readNumber(); + _gameLocation.load(file); + + _field1C = file->readNumber(); + _nodeChangeCtr = 0; + _nodeEnterTicks = 0; +} + +void CGameState::setMode(GameStateMode newMode) { + CScreenManager *sm = CScreenManager::_screenManagerPtr; + + if (newMode == GSMODE_CUTSCENE && newMode != _mode) { + if (_gameManager) + _gameManager->lockInputHandler(); + + if (sm && sm->_mouseCursor) + sm->_mouseCursor->hide(); + + } else if (newMode != GSMODE_CUTSCENE && newMode != _mode) { + if (sm && sm->_mouseCursor) + sm->_mouseCursor->show(); + + if (_gameManager) + _gameManager->unlockInputHandler(); + } + + _mode = newMode; +} + +void CGameState::enterNode() { + ++_nodeChangeCtr; + _nodeEnterTicks = g_vm->_events->getTicksCount(); +} + +void CGameState::enterView() { + CViewItem *oldView = _gameLocation.getView(); + CViewItem *newView = _movieList._view; + oldView->preEnterView(newView); + + _gameManager->_gameView->setView(newView); + CRoomItem *oldRoom = oldView->findNode()->findRoom(); + CRoomItem *newRoom = newView->findNode()->findRoom(); + _gameManager->playClip(_movieList._movieClip, oldRoom, newRoom); + + _gameManager->_sound.preEnterView(newView, newRoom != oldRoom); + _gameManager->dec54(); + oldView->enterView(newView); + + _movieList._view = nullptr; + _movieList._movieClip = nullptr; +} + +void CGameState::triggerLink(CLinkItem *link) { + changeView(link->getDestView(), link->getClip()); +} + +void CGameState::changeView(CViewItem *newView, CMovieClip *clip) { + // Signal the old view that it's being left + CViewItem *oldView = _gameLocation.getView(); + oldView->leaveView(newView); + + // If Shift key is pressed, skip showing the transition clip + if (g_vm->_window->isSpecialPressed(MK_SHIFT)) + clip = nullptr; + + if (_mode == GSMODE_CUTSCENE) { + _movieList._view = newView; + _movieList._movieClip = clip; + } else { + oldView->preEnterView(newView); + _gameManager->_gameView->setView(newView); + CRoomItem *oldRoom = newView->findNode()->findRoom(); + CRoomItem *newRoom = newView->findNode()->findRoom(); + + // If a transition clip is defined, play it + if (clip) + _gameManager->playClip(clip, oldRoom, newRoom); + + // Final view change handling + _gameManager->_sound.preEnterView(newView, newRoom != oldRoom); + oldView->enterView(newView); + } +} + +void CGameState::checkForViewChange() { + if (_mode == GSMODE_CUTSCENE && _movieList.clear()) { + setMode(GSMODE_INTERACTIVE); + if (_movieList._view) + enterView(); + } +} + +void CGameState::addMovie(CMovie *movie) { + _movieList.push_back(new CMovieListItem(movie)); + setMode(GSMODE_CUTSCENE); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h new file mode 100644 index 0000000000..0bfa0d5b31 --- /dev/null +++ b/engines/titanic/game_state.h @@ -0,0 +1,140 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GAME_STATE_H +#define TITANIC_GAME_STATE_H + +#include "titanic/core/list.h" +#include "titanic/core/link_item.h" +#include "titanic/support/simple_file.h" +#include "titanic/game_location.h" +#include "titanic/support/movie.h" + +namespace Titanic { + +class CGameManager; + +enum GameStateMode { + GSMODE_NONE = 0, GSMODE_INTERACTIVE = 1, GSMODE_CUTSCENE = 2, + GSMODE_3 = 3, GSMODE_4 = 4, GSMODE_5 = 5, GSMODE_PENDING_LOAD = 6 +}; + +PTR_LIST_ITEM(CMovie); +class CGameStateMovieList : public List<CMovieListItem> { +public: + CViewItem *_view; + CMovieClip *_movieClip; +public: + CGameStateMovieList() : List<CMovieListItem>(), _view(nullptr), _movieClip(nullptr) {} + + /** + * Clear the movie list + */ + bool clear(); +}; + +class CGameState { +public: + CGameManager *_gameManager; + CGameLocation _gameLocation; + CGameStateMovieList _movieList; + int _passengerClass; + int _priorClass; + GameStateMode _mode; + int _field14; + bool _petActive; + bool _field1C; + bool _quitGame; + int _field24; + uint _nodeChangeCtr; + uint32 _nodeEnterTicks; + Point _mousePos; + int _field38; +public: + CGameState(CGameManager *gameManager); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file) const; + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file); + + /** + * Sets a new mode + */ + void setMode(GameStateMode newMode); + + /** + * Sets the current mouse position + */ + void setMousePos(const Point &pt) { _mousePos = pt; } + + /** + * Gets the current mouse position + */ + Point getMousePos() const { return _mousePos; } + + /** + * Called by the PET when a new node is entered + */ + void enterNode(); + + /** + * Enters a new view + */ + void enterView(); + + /** + * Triggers a link item in a view + */ + void triggerLink(CLinkItem *link); + + /** + * Changes the current view + */ + void changeView(CViewItem *newView, CMovieClip *clip); + + /** + * Check for whether it's time to change the active view + */ + void checkForViewChange(); + + /** + * Adds a movie to the movie list + */ + void addMovie(CMovie *movie); + + void inc14() { _field14 = (_field14 + 1) & 3; } + void set24(int v) { _field24 = v; } + int get24() const { return _field24; } + int getNodeChangedCtr() const { return _nodeChangeCtr; } + uint32 getNodeEnterTicks() const { return _nodeEnterTicks; } + void inc38() { ++_field38; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GAME_STATE_H */ diff --git a/engines/titanic/game_view.cpp b/engines/titanic/game_view.cpp new file mode 100644 index 0000000000..cb84b6a3b1 --- /dev/null +++ b/engines/titanic/game_view.cpp @@ -0,0 +1,96 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/game_view.h" +#include "titanic/game_manager.h" +#include "titanic/main_game_window.h" +#include "titanic/support/screen_manager.h" + +namespace Titanic { + +#define VIEW_OFFSET_X 20 +#define VIEW_OFFSET_Y 10 + +CGameView::CGameView() : _gameManager(nullptr), _surface(nullptr) { +} + +CGameView::~CGameView() { + if (_surface) + delete _surface; +} + +void CGameView::setGameManager(CGameManager *gameManager) { + _gameManager = gameManager; +} + +void CGameView::postLoad() { + delete _surface; + _surface = nullptr; +} + +void CGameView::deleteView(int roomNumber, int nodeNumber, int viewNumber) { + CViewItem *view = _gameManager->_project->findView(roomNumber, nodeNumber, viewNumber); + if (view) + delete view; +} + +void CGameView::createSurface(const CResourceKey &key) { + // Reset any current view surface + _gameManager->initBounds(); + delete _surface; + _surface = nullptr; + + // Create a fresh surface + CScreenManager::setCurrent(); + _surface = CScreenManager::_currentScreenManagerPtr->createSurface(key); + _surface->_fastBlitFlag = true; +} + +void CGameView::drawView() { + CScreenManager::setCurrent(); + Rect srcRect = _gameManager->_bounds; + + Rect rect2(0, 0, 600, 340); + rect2.translate(VIEW_OFFSET_X, VIEW_OFFSET_Y); + srcRect.constrain(rect2); + Common::Point destPos(srcRect.left, srcRect.top); + srcRect.translate(-VIEW_OFFSET_X, -VIEW_OFFSET_Y); + + CScreenManager::_currentScreenManagerPtr->blitFrom(SURFACE_BACKBUFFER, + _surface, &destPos, &srcRect); +} + +/*------------------------------------------------------------------------*/ + +CSTGameView::CSTGameView(CMainGameWindow *gameWindow) : + CGameView(), _gameWindow(gameWindow) { +} + +void CSTGameView::setView(CViewItem *view) { + _gameWindow->setActiveView(view); +} + +void CSTGameView::draw(const Rect &bounds) { + _gameWindow->draw(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/game_view.h b/engines/titanic/game_view.h new file mode 100644 index 0000000000..29e800bc7a --- /dev/null +++ b/engines/titanic/game_view.h @@ -0,0 +1,93 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GAME_VIEW_H +#define TITANIC_GAME_VIEW_H + +#include "common/scummsys.h" +#include "titanic/core/view_item.h" +#include "titanic/support/video_surface.h" + +namespace Titanic { + +class CMainGameWindow; +class CGameManager; + +class CGameView { +protected: + CGameManager *_gameManager; +public: + CVideoSurface *_surface; +public: + CGameView(); + virtual ~CGameView(); + + /** + * Set the game manager + */ + void setGameManager(CGameManager *gameManager); + + /** + * Called after loading a game has finished + */ + void postLoad(); + + virtual void deleteView(int roomNumber, int nodeNumber, int viewNumber); + + /** + * Set the currently active view + */ + virtual void setView(CViewItem *item) = 0; + + virtual void draw(const Rect &bounds) = 0; + + /** + * Creates a surface from a specified resource + */ + void createSurface(const CResourceKey &key); + + /** + * Draws the background of a view + */ + void drawView(); +}; + +class CSTGameView: public CGameView { +private: + CMainGameWindow *_gameWindow; +public: + CSTGameView(CMainGameWindow *gameWindow); + + /** + * Set the currently active view + */ + virtual void setView(CViewItem *item); + + /** + * Handles drawing the view + */ + virtual void draw(const Rect &bounds); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GAME_VIEW_H */ diff --git a/engines/titanic/gfx/act_button.cpp b/engines/titanic/gfx/act_button.cpp new file mode 100644 index 0000000000..75c999b10f --- /dev/null +++ b/engines/titanic/gfx/act_button.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/act_button.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CActButton, CSTButton) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + +CActButton::CActButton() : CSTButton() { +} + +void CActButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSTButton::save(file, indent); +} + +void CActButton::load(SimpleFile *file) { + file->readNumber(); + CSTButton::load(file); +} + +bool CActButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + CActMsg actMsg(_actionName); + actMsg.execute(_actionTarget); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/act_button.h b/engines/titanic/gfx/act_button.h new file mode 100644 index 0000000000..910ace1d13 --- /dev/null +++ b/engines/titanic/gfx/act_button.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ACT_BUTTON_H +#define TITANIC_ACT_BUTTON_H + +#include "titanic/gfx/st_button.h" + +namespace Titanic { + +class CActButton : public CSTButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); +public: + CLASSDEF; + CActButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ACT_BUTTON_H */ diff --git a/engines/titanic/gfx/changes_season_button.cpp b/engines/titanic/gfx/changes_season_button.cpp new file mode 100644 index 0000000000..d5242ad890 --- /dev/null +++ b/engines/titanic/gfx/changes_season_button.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/changes_season_button.h" + +namespace Titanic { + +CChangesSeasonButton::CChangesSeasonButton() : CSTButton() { +} + +void CChangesSeasonButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSTButton::save(file, indent); +} + +void CChangesSeasonButton::load(SimpleFile *file) { + file->readNumber(); + CSTButton::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/changes_season_button.h b/engines/titanic/gfx/changes_season_button.h new file mode 100644 index 0000000000..2b58a3199b --- /dev/null +++ b/engines/titanic/gfx/changes_season_button.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHANGES_SEASON_BUTTON_H +#define TITANIC_CHANGES_SEASON_BUTTON_H + +#include "titanic/gfx/st_button.h" + +namespace Titanic { + +class CChangesSeasonButton : public CSTButton { +public: + CLASSDEF; + CChangesSeasonButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHANGES_SEASON_BUTTON_H */ diff --git a/engines/titanic/gfx/chev_left_off.cpp b/engines/titanic/gfx/chev_left_off.cpp new file mode 100644 index 0000000000..d5c7dcffd6 --- /dev/null +++ b/engines/titanic/gfx/chev_left_off.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/chev_left_off.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CChevLeftOff, CToggleSwitch); + +CChevLeftOff::CChevLeftOff() : CToggleSwitch() { +} + +void CChevLeftOff::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CChevLeftOff::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/chev_left_off.h b/engines/titanic/gfx/chev_left_off.h new file mode 100644 index 0000000000..5034c1a71a --- /dev/null +++ b/engines/titanic/gfx/chev_left_off.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_LEFT_OFF_H +#define TITANIC_CHEV_LEFT_OFF_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CChevLeftOff : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CChevLeftOff(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_LEFT_OFF_H */ diff --git a/engines/titanic/gfx/chev_left_on.cpp b/engines/titanic/gfx/chev_left_on.cpp new file mode 100644 index 0000000000..9b4a5b6d58 --- /dev/null +++ b/engines/titanic/gfx/chev_left_on.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/chev_left_on.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CChevLeftOn, CToggleSwitch); + +CChevLeftOn::CChevLeftOn() : CToggleSwitch() { +} + +void CChevLeftOn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CChevLeftOn::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/chev_left_on.h b/engines/titanic/gfx/chev_left_on.h new file mode 100644 index 0000000000..df430f6700 --- /dev/null +++ b/engines/titanic/gfx/chev_left_on.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_LEFT_ON_H +#define TITANIC_CHEV_LEFT_ON_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CChevLeftOn : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CChevLeftOn(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_LEFT_ON_H */ diff --git a/engines/titanic/gfx/chev_right_off.cpp b/engines/titanic/gfx/chev_right_off.cpp new file mode 100644 index 0000000000..c4ff3628a0 --- /dev/null +++ b/engines/titanic/gfx/chev_right_off.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/chev_right_off.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CChevRightOff, CToggleSwitch); + +CChevRightOff::CChevRightOff() : CToggleSwitch() { +} + +void CChevRightOff::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CChevRightOff::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/chev_right_off.h b/engines/titanic/gfx/chev_right_off.h new file mode 100644 index 0000000000..8f6c3fc254 --- /dev/null +++ b/engines/titanic/gfx/chev_right_off.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_RIGHT_OFF_H +#define TITANIC_CHEV_RIGHT_OFF_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CChevRightOff : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CChevRightOff(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_RIGHT_OFF_H */ diff --git a/engines/titanic/gfx/chev_right_on.cpp b/engines/titanic/gfx/chev_right_on.cpp new file mode 100644 index 0000000000..0351c105d2 --- /dev/null +++ b/engines/titanic/gfx/chev_right_on.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/chev_right_on.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CChevRightOn, CToggleSwitch); + +CChevRightOn::CChevRightOn() : CToggleSwitch() { +} + +void CChevRightOn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CChevRightOn::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/chev_right_on.h b/engines/titanic/gfx/chev_right_on.h new file mode 100644 index 0000000000..accd42cff8 --- /dev/null +++ b/engines/titanic/gfx/chev_right_on.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_RIGHT_ON_H +#define TITANIC_CHEV_RIGHT_ON_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CChevRightOn : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CChevRightOn(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_RIGHT_ON_H */ diff --git a/engines/titanic/gfx/chev_send_rec_switch.cpp b/engines/titanic/gfx/chev_send_rec_switch.cpp new file mode 100644 index 0000000000..6e30280315 --- /dev/null +++ b/engines/titanic/gfx/chev_send_rec_switch.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/chev_send_rec_switch.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CChevSendRecSwitch, CToggleSwitch); + +CChevSendRecSwitch::CChevSendRecSwitch() : CToggleSwitch() { +} + +void CChevSendRecSwitch::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CChevSendRecSwitch::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/chev_send_rec_switch.h b/engines/titanic/gfx/chev_send_rec_switch.h new file mode 100644 index 0000000000..b3ccab2f09 --- /dev/null +++ b/engines/titanic/gfx/chev_send_rec_switch.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_SEND_REC_SWITCH_H +#define TITANIC_CHEV_SEND_REC_SWITCH_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CChevSendRecSwitch : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CChevSendRecSwitch(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_SEND_REC_SWITCH_H */ diff --git a/engines/titanic/gfx/chev_switch.cpp b/engines/titanic/gfx/chev_switch.cpp new file mode 100644 index 0000000000..a6ce93098c --- /dev/null +++ b/engines/titanic/gfx/chev_switch.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/chev_switch.h" + +namespace Titanic { + +CChevSwitch::CChevSwitch() : CToggleSwitch() { +} + +void CChevSwitch::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CChevSwitch::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/chev_switch.h b/engines/titanic/gfx/chev_switch.h new file mode 100644 index 0000000000..0305a6ca83 --- /dev/null +++ b/engines/titanic/gfx/chev_switch.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHEV_SWITCH_H +#define TITANIC_CHEV_SWITCH_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CChevSwitch : public CToggleSwitch { +public: + CLASSDEF; + CChevSwitch(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHEV_SWITCH_H */ diff --git a/engines/titanic/gfx/edit_control.cpp b/engines/titanic/gfx/edit_control.cpp new file mode 100644 index 0000000000..3b611e9bbe --- /dev/null +++ b/engines/titanic/gfx/edit_control.cpp @@ -0,0 +1,72 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/edit_control.h" + +namespace Titanic { + +CEditControl::CEditControl() : CGameObject(), _fieldBC(0), _fieldC0(0), + _fieldC4(0), _fieldC8(0), _fieldCC(0), _fieldD0(0), _fieldD4(2), + _fieldD8(0), _fieldDC(0), _fieldE0(0), _fieldF0(0), _fieldF4(0) + +{ +} + +void CEditControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeNumberLine(_fieldD0, indent); + file->writeNumberLine(_fieldD4, indent); + file->writeNumberLine(_fieldD8, indent); + file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + + CGameObject::save(file, indent); +} + +void CEditControl::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + _fieldD0 = file->readNumber(); + _fieldD4 = file->readNumber(); + _fieldD8 = file->readNumber(); + _fieldDC = file->readNumber(); + _fieldE0 = file->readNumber(); + _string1 = file->readString(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/edit_control.h b/engines/titanic/gfx/edit_control.h new file mode 100644 index 0000000000..77d03cb225 --- /dev/null +++ b/engines/titanic/gfx/edit_control.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EDIT_CONTROL_H +#define TITANIC_EDIT_CONTROL_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CEditControl : public CGameObject { +protected: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; + int _fieldD0; + int _fieldD4; + int _fieldD8; + int _fieldDC; + int _fieldE0; + CString _string1; + int _fieldF0; + int _fieldF4; +public: + CLASSDEF; + CEditControl(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EDIT_CONTROL_H */ diff --git a/engines/titanic/gfx/elevator_button.cpp b/engines/titanic/gfx/elevator_button.cpp new file mode 100644 index 0000000000..e66ee19af3 --- /dev/null +++ b/engines/titanic/gfx/elevator_button.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/elevator_button.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CElevatorButton, CSTButton); + +CElevatorButton::CElevatorButton() : CSTButton() { +} + +void CElevatorButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSTButton::save(file, indent); +} + +void CElevatorButton::load(SimpleFile *file) { + file->readNumber(); + CSTButton::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/elevator_button.h b/engines/titanic/gfx/elevator_button.h new file mode 100644 index 0000000000..28110d8102 --- /dev/null +++ b/engines/titanic/gfx/elevator_button.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ELEVATOR_BUTTON_H +#define TITANIC_ELEVATOR_BUTTON_H + +#include "titanic/gfx/st_button.h" + +namespace Titanic { + +class CElevatorButton : public CSTButton { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CElevatorButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ELEVATOR_BUTTON_H */ diff --git a/engines/titanic/gfx/get_from_succ.cpp b/engines/titanic/gfx/get_from_succ.cpp new file mode 100644 index 0000000000..d701f73537 --- /dev/null +++ b/engines/titanic/gfx/get_from_succ.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/get_from_succ.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CGetFromSucc, CToggleSwitch); + +CGetFromSucc::CGetFromSucc() : CToggleSwitch() { +} + +void CGetFromSucc::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CGetFromSucc::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/get_from_succ.h b/engines/titanic/gfx/get_from_succ.h new file mode 100644 index 0000000000..f85f1b4cf2 --- /dev/null +++ b/engines/titanic/gfx/get_from_succ.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GET_FROM_SUCC_H +#define TITANIC_GET_FROM_SUCC_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CGetFromSucc : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CGetFromSucc(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GET_FROM_SUCC_H */ diff --git a/engines/titanic/gfx/helmet_on_off.cpp b/engines/titanic/gfx/helmet_on_off.cpp new file mode 100644 index 0000000000..06e7d43d32 --- /dev/null +++ b/engines/titanic/gfx/helmet_on_off.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/helmet_on_off.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CHelmetOnOff, CToggleSwitch); + +CHelmetOnOff::CHelmetOnOff() : CToggleSwitch() { +} + +void CHelmetOnOff::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CHelmetOnOff::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/helmet_on_off.h b/engines/titanic/gfx/helmet_on_off.h new file mode 100644 index 0000000000..c2910eb59d --- /dev/null +++ b/engines/titanic/gfx/helmet_on_off.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HELMET_ON_OFF_H +#define TITANIC_HELMET_ON_OFF_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CHelmetOnOff : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CHelmetOnOff(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HELMET_ON_OFF_H */ diff --git a/engines/titanic/gfx/home_photo.cpp b/engines/titanic/gfx/home_photo.cpp new file mode 100644 index 0000000000..758a5caa75 --- /dev/null +++ b/engines/titanic/gfx/home_photo.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/home_photo.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CHomePhoto, CToggleSwitch); + +CHomePhoto::CHomePhoto() : CToggleSwitch() { +} + +void CHomePhoto::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CHomePhoto::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/home_photo.h b/engines/titanic/gfx/home_photo.h new file mode 100644 index 0000000000..09b18b7c0f --- /dev/null +++ b/engines/titanic/gfx/home_photo.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_HOME_PHOTO_H +#define TITANIC_HOME_PHOTO_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CHomePhoto : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CHomePhoto(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_HOME_PHOTO_H */ diff --git a/engines/titanic/gfx/icon_nav_action.cpp b/engines/titanic/gfx/icon_nav_action.cpp new file mode 100644 index 0000000000..4d32f46571 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_action.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_action.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavAction, CToggleSwitch); + +CIconNavAction::CIconNavAction() : CToggleSwitch() { +} + +void CIconNavAction::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CIconNavAction::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_action.h b/engines/titanic/gfx/icon_nav_action.h new file mode 100644 index 0000000000..841334dd41 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_action.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_ACTION_H +#define TITANIC_ICON_NAV_ACTION_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CIconNavAction : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CIconNavAction(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_ACTION_H */ diff --git a/engines/titanic/gfx/icon_nav_butt.cpp b/engines/titanic/gfx/icon_nav_butt.cpp new file mode 100644 index 0000000000..951c2f5e7b --- /dev/null +++ b/engines/titanic/gfx/icon_nav_butt.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_butt.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavButt, CPetGraphic); + +void CIconNavButt::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CIconNavButt::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_butt.h b/engines/titanic/gfx/icon_nav_butt.h new file mode 100644 index 0000000000..c60877e2c0 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_butt.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_BUTT_H +#define TITANIC_ICON_NAV_BUTT_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CIconNavButt : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_BUTT_H */ diff --git a/engines/titanic/gfx/icon_nav_down.cpp b/engines/titanic/gfx/icon_nav_down.cpp new file mode 100644 index 0000000000..efa2124b14 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_down.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_down.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavDown, CToggleSwitch); + +CIconNavDown::CIconNavDown() : CToggleSwitch() { +} + +void CIconNavDown::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CIconNavDown::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_down.h b/engines/titanic/gfx/icon_nav_down.h new file mode 100644 index 0000000000..6c0c2870e4 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_down.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_DOWN_H +#define TITANIC_ICON_NAV_DOWN_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CIconNavDown : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CIconNavDown(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_DOWN_H */ diff --git a/engines/titanic/gfx/icon_nav_image.cpp b/engines/titanic/gfx/icon_nav_image.cpp new file mode 100644 index 0000000000..403ae44b17 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_image.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_image.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavImage, CPetGraphic); + +void CIconNavImage::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CIconNavImage::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_image.h b/engines/titanic/gfx/icon_nav_image.h new file mode 100644 index 0000000000..580762c32d --- /dev/null +++ b/engines/titanic/gfx/icon_nav_image.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_IMAGE_H +#define TITANIC_ICON_NAV_IMAGE_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CIconNavImage : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_IMAGE_H */ diff --git a/engines/titanic/gfx/icon_nav_left.cpp b/engines/titanic/gfx/icon_nav_left.cpp new file mode 100644 index 0000000000..8d98f3724c --- /dev/null +++ b/engines/titanic/gfx/icon_nav_left.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_left.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavLeft, CToggleSwitch); + +CIconNavLeft::CIconNavLeft() : CToggleSwitch() { +} + +void CIconNavLeft::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CIconNavLeft::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_left.h b/engines/titanic/gfx/icon_nav_left.h new file mode 100644 index 0000000000..bb61c26362 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_left.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_LEFT_H +#define TITANIC_ICON_NAV_LEFT_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CIconNavLeft : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CIconNavLeft(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_LEFT_H */ diff --git a/engines/titanic/gfx/icon_nav_receive.cpp b/engines/titanic/gfx/icon_nav_receive.cpp new file mode 100644 index 0000000000..e3e0986690 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_receive.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_receive.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavReceive, CPetGraphic); + +void CIconNavReceive::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CIconNavReceive::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_receive.h b/engines/titanic/gfx/icon_nav_receive.h new file mode 100644 index 0000000000..0744105835 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_receive.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_RECEIVE_H +#define TITANIC_ICON_NAV_RECEIVE_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CIconNavReceive : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_RECEIVE_H */ diff --git a/engines/titanic/gfx/icon_nav_right.cpp b/engines/titanic/gfx/icon_nav_right.cpp new file mode 100644 index 0000000000..de827918e9 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_right.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_right.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavRight, CToggleSwitch); + +CIconNavRight::CIconNavRight() : CToggleSwitch() { +} + +void CIconNavRight::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CIconNavRight::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_right.h b/engines/titanic/gfx/icon_nav_right.h new file mode 100644 index 0000000000..a1bed9ca8f --- /dev/null +++ b/engines/titanic/gfx/icon_nav_right.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_RIGHT_H +#define TITANIC_ICON_NAV_RIGHT_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CIconNavRight : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CIconNavRight(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_RIGHT_H */ diff --git a/engines/titanic/gfx/icon_nav_send.cpp b/engines/titanic/gfx/icon_nav_send.cpp new file mode 100644 index 0000000000..9baa9e8f33 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_send.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_send.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavSend, CPetGraphic); + +void CIconNavSend::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CIconNavSend::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_send.h b/engines/titanic/gfx/icon_nav_send.h new file mode 100644 index 0000000000..f3af8d9c65 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_send.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_SEND_H +#define TITANIC_ICON_NAV_SEND_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CIconNavSend : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_SEND_H */ diff --git a/engines/titanic/gfx/icon_nav_up.cpp b/engines/titanic/gfx/icon_nav_up.cpp new file mode 100644 index 0000000000..4268d97868 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_up.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/icon_nav_up.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CIconNavUp, CToggleSwitch); + +CIconNavUp::CIconNavUp() : CToggleSwitch() { +} + +void CIconNavUp::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CIconNavUp::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/icon_nav_up.h b/engines/titanic/gfx/icon_nav_up.h new file mode 100644 index 0000000000..4b7320d610 --- /dev/null +++ b/engines/titanic/gfx/icon_nav_up.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ICON_NAV_UP_H +#define TITANIC_ICON_NAV_UP_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CIconNavUp : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CIconNavUp(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ICON_NAV_UP_H */ diff --git a/engines/titanic/gfx/keybrd_butt.cpp b/engines/titanic/gfx/keybrd_butt.cpp new file mode 100644 index 0000000000..063e709a7b --- /dev/null +++ b/engines/titanic/gfx/keybrd_butt.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/keybrd_butt.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CKeybrdButt, CToggleSwitch); + +CKeybrdButt::CKeybrdButt() : CToggleSwitch() { +} + +void CKeybrdButt::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CKeybrdButt::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/keybrd_butt.h b/engines/titanic/gfx/keybrd_butt.h new file mode 100644 index 0000000000..822be41ed2 --- /dev/null +++ b/engines/titanic/gfx/keybrd_butt.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_KEYBRD_BUTT_H +#define TITANIC_KEYBRD_BUTT_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CKeybrdButt : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CKeybrdButt(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_KEYBRD_BUTT_H */ diff --git a/engines/titanic/gfx/move_object_button.cpp b/engines/titanic/gfx/move_object_button.cpp new file mode 100644 index 0000000000..bdc90a673c --- /dev/null +++ b/engines/titanic/gfx/move_object_button.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/move_object_button.h" + +namespace Titanic { + +CMoveObjectButton::CMoveObjectButton() : CSTButton(), _field11C(1) { +} + +void CMoveObjectButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writePoint(_pos1, indent); + file->writeNumberLine(_field11C, indent); + + CSTButton::save(file, indent); +} + +void CMoveObjectButton::load(SimpleFile *file) { + file->readNumber(); + _pos1 = file->readPoint(); + _field11C = file->readNumber(); + + CSTButton::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/move_object_button.h b/engines/titanic/gfx/move_object_button.h new file mode 100644 index 0000000000..eb2fdc4ff2 --- /dev/null +++ b/engines/titanic/gfx/move_object_button.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVE_OBJECT_BUTTON_H +#define TITANIC_MOVE_OBJECT_BUTTON_H + +#include "titanic/gfx/st_button.h" + +namespace Titanic { + +class CMoveObjectButton : public CSTButton { +private: + Point _pos1; + int _field11C; +public: + CLASSDEF; + CMoveObjectButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVE_OBJECT_BUTTON_H */ diff --git a/engines/titanic/gfx/music_control.cpp b/engines/titanic/gfx/music_control.cpp new file mode 100644 index 0000000000..85a3d777ef --- /dev/null +++ b/engines/titanic/gfx/music_control.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/music_control.h" + +namespace Titanic { + +CMusicControl::CMusicControl() : CBackground(), + _fieldE0(0), _fieldE4(0), _fieldE8(1), _fieldEC(1) { +} + +void CMusicControl::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); + + CBackground::save(file, indent); +} + +void CMusicControl::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_control.h b/engines/titanic/gfx/music_control.h new file mode 100644 index 0000000000..04085f789c --- /dev/null +++ b/engines/titanic/gfx/music_control.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_CONTROL_H +#define TITANIC_MUSIC_CONTROL_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CMusicControl : public CBackground { +public: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; +public: + CLASSDEF; + CMusicControl(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_CONTROL_H */ diff --git a/engines/titanic/gfx/music_slider.cpp b/engines/titanic/gfx/music_slider.cpp new file mode 100644 index 0000000000..ec7ff5e3f6 --- /dev/null +++ b/engines/titanic/gfx/music_slider.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/music_slider.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CMusicSlider, CMusicControl); + +void CMusicSlider::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicControl::save(file, indent); +} + +void CMusicSlider::load(SimpleFile *file) { + file->readNumber(); + CMusicControl::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_slider.h b/engines/titanic/gfx/music_slider.h new file mode 100644 index 0000000000..be2c5631b6 --- /dev/null +++ b/engines/titanic/gfx/music_slider.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_SLIDER_H +#define TITANIC_MUSIC_SLIDER_H + +#include "titanic/gfx/music_control.h" + +namespace Titanic { + +class CMusicSlider : public CMusicControl { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SLIDER_H */ diff --git a/engines/titanic/gfx/music_slider_pitch.h b/engines/titanic/gfx/music_slider_pitch.h new file mode 100644 index 0000000000..10c1d62c3a --- /dev/null +++ b/engines/titanic/gfx/music_slider_pitch.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_SLIDER_PITCH_H +#define TITANIC_MUSIC_SLIDER_PITCH_H + +#include "titanic/gfx/music_slider.h" + +namespace Titanic { + +class CMusicSliderPitch : public CMusicSlider { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSlider::save(file, indent); + } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file) { + file->readNumber(); + CMusicSlider::load(file); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SLIDER_PITCH_H */ diff --git a/engines/titanic/gfx/music_slider_speed.h b/engines/titanic/gfx/music_slider_speed.h new file mode 100644 index 0000000000..9814ca0312 --- /dev/null +++ b/engines/titanic/gfx/music_slider_speed.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef TITANIC_MUSIC_SLIDER_SPEED_H +#define TITANIC_MUSIC_SLIDER_SPEED_H + +#include "titanic/gfx/music_slider.h" + +namespace Titanic { + + class CMusicSliderSpeed : public CMusicSlider { + public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSlider::save(file, indent); + } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file) { + file->readNumber(); + CMusicSlider::load(file); + } + }; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SLIDER_SPEED_H */ diff --git a/engines/titanic/gfx/music_switch.cpp b/engines/titanic/gfx/music_switch.cpp new file mode 100644 index 0000000000..1c2ced0b4e --- /dev/null +++ b/engines/titanic/gfx/music_switch.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/music_switch.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CMusicSwitch, CMusicControl); + +void CMusicSwitch::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicControl::save(file, indent); +} + +void CMusicSwitch::load(SimpleFile *file) { + file->readNumber(); + CMusicControl::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_switch.h b/engines/titanic/gfx/music_switch.h new file mode 100644 index 0000000000..35af84bdbf --- /dev/null +++ b/engines/titanic/gfx/music_switch.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_SWITCH_H +#define TITANIC_MUSIC_SWITCH_H + +#include "titanic/gfx/music_control.h" + +namespace Titanic { + +class CMusicSwitch : public CMusicControl { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SWITCH_H */ diff --git a/engines/titanic/gfx/music_switch_inversion.h b/engines/titanic/gfx/music_switch_inversion.h new file mode 100644 index 0000000000..8b3718cf14 --- /dev/null +++ b/engines/titanic/gfx/music_switch_inversion.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_SWITCH_INVERSION_H +#define TITANIC_MUSIC_SWITCH_INVERSION_H + +#include "titanic/gfx/music_switch.h" + +namespace Titanic { + +class CMusicSwitchInversion : public CMusicSwitch { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSwitch::save(file, indent); + } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file) { + file->readNumber(); + CMusicSwitch::load(file); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SWITCH_INVERSION_H */ diff --git a/engines/titanic/gfx/music_switch_reverse.h b/engines/titanic/gfx/music_switch_reverse.h new file mode 100644 index 0000000000..3bfcb53b00 --- /dev/null +++ b/engines/titanic/gfx/music_switch_reverse.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#ifndef TITANIC_MUSIC_SWITCH_REVERSE_H +#define TITANIC_MUSIC_SWITCH_REVERSE_H + +#include "titanic/gfx/music_switch.h" + +namespace Titanic { + + class CMusicSwitchReverse : public CMusicSwitch { + public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSwitch::save(file, indent); + } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file) { + file->readNumber(); + CMusicSwitch::load(file); + } + }; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_SWITCH_REVERSE_H */ diff --git a/engines/titanic/gfx/music_voice_mute.h b/engines/titanic/gfx/music_voice_mute.h new file mode 100644 index 0000000000..ca15806c09 --- /dev/null +++ b/engines/titanic/gfx/music_voice_mute.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_VOICE_MUTE_H +#define TITANIC_MUSIC_VOICE_MUTE_H + +#include "titanic/gfx/music_control.h" + +namespace Titanic { + +class CMusicVoiceMute : public CMusicControl { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicControl::save(file, indent); + } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file) { + file->readNumber(); + CMusicControl::load(file); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_VOICE_MUTE_H */ diff --git a/engines/titanic/gfx/send_to_succ.cpp b/engines/titanic/gfx/send_to_succ.cpp new file mode 100644 index 0000000000..0e2b83361b --- /dev/null +++ b/engines/titanic/gfx/send_to_succ.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/send_to_succ.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CSendToSucc, CToggleSwitch); + +CSendToSucc::CSendToSucc() : CToggleSwitch() { +} + +void CSendToSucc::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CSendToSucc::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/send_to_succ.h b/engines/titanic/gfx/send_to_succ.h new file mode 100644 index 0000000000..734c4a7db3 --- /dev/null +++ b/engines/titanic/gfx/send_to_succ.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SEND_TO_SUCC_H +#define TITANIC_SEND_TO_SUCC_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CSendToSucc : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CSendToSucc(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SEND_TO_SUCC_H */ diff --git a/engines/titanic/gfx/sgt_selector.cpp b/engines/titanic/gfx/sgt_selector.cpp new file mode 100644 index 0000000000..81cccb72ce --- /dev/null +++ b/engines/titanic/gfx/sgt_selector.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/sgt_selector.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CSGTSelector, CPetGraphic); + +void CSGTSelector::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CSGTSelector::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/sgt_selector.h b/engines/titanic/gfx/sgt_selector.h new file mode 100644 index 0000000000..be35635c2b --- /dev/null +++ b/engines/titanic/gfx/sgt_selector.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SGT_SELECTOR_H +#define TITANIC_SGT_SELECTOR_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CSGTSelector : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SGT_SELECTOR_H */ diff --git a/engines/titanic/gfx/slider_button.cpp b/engines/titanic/gfx/slider_button.cpp new file mode 100644 index 0000000000..0633158e97 --- /dev/null +++ b/engines/titanic/gfx/slider_button.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/slider_button.h" + +namespace Titanic { + +CSliderButton::CSliderButton() : CSTButton(), _field114(0), + _field118(0), _field11C(0) { +} + +void CSliderButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field114, indent); + file->writeNumberLine(_field118, indent); + file->writeNumberLine(_field11C, indent); + file->writePoint(_pos1, indent); + + CSTButton::save(file, indent); +} + +void CSliderButton::load(SimpleFile *file) { + file->readNumber(); + _field114 = file->readNumber(); + _field118 = file->readNumber(); + _field11C = file->readNumber(); + _pos1 = file->readPoint(); + + CSTButton::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/slider_button.h b/engines/titanic/gfx/slider_button.h new file mode 100644 index 0000000000..398290bb05 --- /dev/null +++ b/engines/titanic/gfx/slider_button.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SLIDER_BUTTON_H +#define TITANIC_SLIDER_BUTTON_H + +#include "titanic/gfx/st_button.h" + +namespace Titanic { + +class CSliderButton : public CSTButton { +private: + int _field114; + int _field118; + int _field11C; + Point _pos1; +public: + CLASSDEF; + CSliderButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SLIDER_BUTTON_H */ diff --git a/engines/titanic/gfx/small_chev_left_off.cpp b/engines/titanic/gfx/small_chev_left_off.cpp new file mode 100644 index 0000000000..f7c27f9036 --- /dev/null +++ b/engines/titanic/gfx/small_chev_left_off.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/small_chev_left_off.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CSmallChevLeftOff, CToggleSwitch); + +CSmallChevLeftOff::CSmallChevLeftOff() : CToggleSwitch() { +} + +void CSmallChevLeftOff::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CSmallChevLeftOff::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/small_chev_left_off.h b/engines/titanic/gfx/small_chev_left_off.h new file mode 100644 index 0000000000..bed64befdb --- /dev/null +++ b/engines/titanic/gfx/small_chev_left_off.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SMALL_CHEV_LEFT_OFF_H +#define TITANIC_SMALL_CHEV_LEFT_OFF_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CSmallChevLeftOff : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CSmallChevLeftOff(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SMALL_CHEV_LEFT_OFF_H */ diff --git a/engines/titanic/gfx/small_chev_left_on.cpp b/engines/titanic/gfx/small_chev_left_on.cpp new file mode 100644 index 0000000000..7a82c1878e --- /dev/null +++ b/engines/titanic/gfx/small_chev_left_on.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/small_chev_left_on.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CSmallChevLeftOn, CToggleSwitch); + +CSmallChevLeftOn::CSmallChevLeftOn() : CToggleSwitch() { +} + +void CSmallChevLeftOn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CSmallChevLeftOn::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/small_chev_left_on.h b/engines/titanic/gfx/small_chev_left_on.h new file mode 100644 index 0000000000..9d1771311c --- /dev/null +++ b/engines/titanic/gfx/small_chev_left_on.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SMALL_CHEV_LEFT_ON_H +#define TITANIC_SMALL_CHEV_LEFT_ON_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CSmallChevLeftOn : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CSmallChevLeftOn(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SMALL_CHEV_LEFT_ON_H */ diff --git a/engines/titanic/gfx/small_chev_right_off.cpp b/engines/titanic/gfx/small_chev_right_off.cpp new file mode 100644 index 0000000000..f07c5a3d00 --- /dev/null +++ b/engines/titanic/gfx/small_chev_right_off.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/small_chev_right_off.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CSmallChevRightOff, CToggleSwitch); + +CSmallChevRightOff::CSmallChevRightOff() : CToggleSwitch() { +} + +void CSmallChevRightOff::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CSmallChevRightOff::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/small_chev_right_off.h b/engines/titanic/gfx/small_chev_right_off.h new file mode 100644 index 0000000000..eb6ca455d2 --- /dev/null +++ b/engines/titanic/gfx/small_chev_right_off.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SMALL_CHEV_RIGHT_OFF_H +#define TITANIC_SMALL_CHEV_RIGHT_OFF_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CSmallChevRightOff : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CSmallChevRightOff(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SMALL_CHEV_RIGHT_OFF_H */ diff --git a/engines/titanic/gfx/small_chev_right_on.cpp b/engines/titanic/gfx/small_chev_right_on.cpp new file mode 100644 index 0000000000..18aba4a91f --- /dev/null +++ b/engines/titanic/gfx/small_chev_right_on.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/small_chev_right_on.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CSmallChevRightOn, CToggleSwitch); + +CSmallChevRightOn::CSmallChevRightOn() : CToggleSwitch() { +} + +void CSmallChevRightOn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CSmallChevRightOn::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/small_chev_right_on.h b/engines/titanic/gfx/small_chev_right_on.h new file mode 100644 index 0000000000..1dfb2d6fb2 --- /dev/null +++ b/engines/titanic/gfx/small_chev_right_on.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SMALL_CHEV_RIGHT_ON_H +#define TITANIC_SMALL_CHEV_RIGHT_ON_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CSmallChevRightOn : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CSmallChevRightOn(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SMALL_CHEV_RIGHT_ON_H */ diff --git a/engines/titanic/gfx/st_button.cpp b/engines/titanic/gfx/st_button.cpp new file mode 100644 index 0000000000..6fc31f4c64 --- /dev/null +++ b/engines/titanic/gfx/st_button.cpp @@ -0,0 +1,96 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/st_button.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CSTButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CSTButton::CSTButton() : CBackground() { + _statusInc = 0; + _actionTarget = "NULL"; + _fieldF0 = 0; + _currentStatus = 0; + _actionName = "NULL"; + _soundName = "NULL"; + _buttonFrame = 0; +} + +void CSTButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_statusInc, indent); + file->writeQuotedLine(_actionTarget, indent); + file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_currentStatus, indent); + file->writeQuotedLine(_actionName, indent); + file->writeQuotedLine(_soundName, indent); + file->writeNumberLine(_buttonFrame, indent); + + CBackground::save(file, indent); +} + +void CSTButton::load(SimpleFile *file) { + file->readNumber(); + _statusInc = file->readNumber(); + _actionTarget = file->readString(); + _fieldF0 = file->readNumber(); + _currentStatus = file->readNumber(); + _actionName = file->readString(); + _soundName = file->readString(); + _buttonFrame = file->readNumber() != 0; + + CBackground::load(file); +} + +bool CSTButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + playMovie(0); + playSound(_soundName, 100, 0, 0); + + return true; +} + +bool CSTButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + int oldStatus = _currentStatus; + int newStatus = _currentStatus + _statusInc; + + CStatusChangeMsg statusMsg(oldStatus, newStatus, false); + _currentStatus = newStatus; + statusMsg.execute(_actionTarget); + + if (!statusMsg._success) { + _currentStatus -= _statusInc; + } + + return true; +} + +bool CSTButton::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_buttonFrame); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/st_button.h b/engines/titanic/gfx/st_button.h new file mode 100644 index 0000000000..444c883f59 --- /dev/null +++ b/engines/titanic/gfx/st_button.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ST_BUTTON_H +#define TITANIC_ST_BUTTON_H + +#include "titanic/core/background.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CSTButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); +protected: + int _statusInc; + CString _actionTarget; + int _fieldF0; + int _currentStatus; + CString _actionName; + CString _soundName; + int _buttonFrame; +public: + CLASSDEF; + CSTButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ST_BUTTON_H */ diff --git a/engines/titanic/gfx/status_change_button.cpp b/engines/titanic/gfx/status_change_button.cpp new file mode 100644 index 0000000000..6644247ff2 --- /dev/null +++ b/engines/titanic/gfx/status_change_button.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/status_change_button.h" + +namespace Titanic { + +CStatusChangeButton::CStatusChangeButton() : CSTButton() { +} + +void CStatusChangeButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CSTButton::save(file, indent); +} + +void CStatusChangeButton::load(SimpleFile *file) { + file->readNumber(); + CSTButton::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/status_change_button.h b/engines/titanic/gfx/status_change_button.h new file mode 100644 index 0000000000..9e410c66f2 --- /dev/null +++ b/engines/titanic/gfx/status_change_button.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STATUS_CHANGE_BUTTON_H +#define TITANIC_STATUS_CHANGE_BUTTON_H + +#include "titanic/gfx/st_button.h" + +namespace Titanic { + +class CStatusChangeButton : public CSTButton { +public: + CLASSDEF; + CStatusChangeButton(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STATUS_CHANGE_BUTTON_H */ diff --git a/engines/titanic/gfx/text_down.cpp b/engines/titanic/gfx/text_down.cpp new file mode 100644 index 0000000000..4d9bb0b077 --- /dev/null +++ b/engines/titanic/gfx/text_down.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/text_down.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CTextDown, CPetGraphic); + +void CTextDown::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CTextDown::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/text_down.h b/engines/titanic/gfx/text_down.h new file mode 100644 index 0000000000..97660605d5 --- /dev/null +++ b/engines/titanic/gfx/text_down.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TEXT_DOWN_H +#define TITANIC_TEXT_DOWN_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CTextDown : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TEXT_DOWN_H */ diff --git a/engines/titanic/gfx/text_skrew.cpp b/engines/titanic/gfx/text_skrew.cpp new file mode 100644 index 0000000000..6d403eabfb --- /dev/null +++ b/engines/titanic/gfx/text_skrew.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/text_skrew.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CTextSkrew, CPetGraphic); + +void CTextSkrew::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CTextSkrew::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/text_skrew.h b/engines/titanic/gfx/text_skrew.h new file mode 100644 index 0000000000..d0d9b82afd --- /dev/null +++ b/engines/titanic/gfx/text_skrew.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TEXT_SKREW_H +#define TITANIC_TEXT_SKREW_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CTextSkrew : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TEXT_SKREW_H */ diff --git a/engines/titanic/gfx/text_up.cpp b/engines/titanic/gfx/text_up.cpp new file mode 100644 index 0000000000..842be63ee6 --- /dev/null +++ b/engines/titanic/gfx/text_up.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/text_up.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CTextUp, CPetGraphic); + +void CTextUp::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CTextUp::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/text_up.h b/engines/titanic/gfx/text_up.h new file mode 100644 index 0000000000..dda8d8461b --- /dev/null +++ b/engines/titanic/gfx/text_up.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TEXT_UP_H +#define TITANIC_TEXT_UP_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CTextUp : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TEXT_UP_H */ diff --git a/engines/titanic/gfx/toggle_button.cpp b/engines/titanic/gfx/toggle_button.cpp new file mode 100644 index 0000000000..2b7c80d3df --- /dev/null +++ b/engines/titanic/gfx/toggle_button.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/toggle_button.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CToggleButton, CBackground); + +void CToggleButton::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldE0, indent); + + CBackground::save(file, indent); +} + +void CToggleButton::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + + CBackground::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/toggle_button.h b/engines/titanic/gfx/toggle_button.h new file mode 100644 index 0000000000..5328072982 --- /dev/null +++ b/engines/titanic/gfx/toggle_button.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TOGGLE_BUTTON_H +#define TITANIC_TOGGLE_BUTTON_H + +#include "titanic/core/background.h" + +namespace Titanic { + +class CToggleButton : public CBackground { + DECLARE_MESSAGE_MAP; +private: + int _fieldE0; +public: + CLASSDEF; + CToggleButton() : CBackground(), _fieldE0(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TOGGLE_BUTTON_H */ diff --git a/engines/titanic/gfx/toggle_switch.cpp b/engines/titanic/gfx/toggle_switch.cpp new file mode 100644 index 0000000000..20cbb863ee --- /dev/null +++ b/engines/titanic/gfx/toggle_switch.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +CToggleSwitch::CToggleSwitch() : CGameObject(), _fieldBC(0) { +} + +void CToggleSwitch::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writePoint(_pos1, indent); + + CGameObject::save(file, indent); +} + +void CToggleSwitch::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _pos1 = file->readPoint(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/toggle_switch.h b/engines/titanic/gfx/toggle_switch.h new file mode 100644 index 0000000000..ae96c75ebd --- /dev/null +++ b/engines/titanic/gfx/toggle_switch.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TOGGLE_SWITCH_H +#define TITANIC_TOGGLE_SWITCH_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CToggleSwitch : public CGameObject { +private: + int _fieldBC; + Point _pos1; +public: + CLASSDEF; + CToggleSwitch(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TOGGLE_SWITCH_H */ diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp new file mode 100644 index 0000000000..7c35a5d855 --- /dev/null +++ b/engines/titanic/input_handler.cpp @@ -0,0 +1,177 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/input_handler.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/support/screen_manager.h" + +namespace Titanic { + +CInputHandler::CInputHandler(CGameManager *owner) : + _gameManager(owner), _inputTranslator(nullptr), _dragging(false), + _buttonDown(false), _dragItem(nullptr), _lockCount(0), + _singleton(false) { + CScreenManager::_screenManagerPtr->_inputHandler = this; +} + +void CInputHandler::setTranslator(CInputTranslator *translator) { + _inputTranslator = translator; +} + +void CInputHandler::incLockCount() { + ++_lockCount; +} + +void CInputHandler::decLockCount() { + if (--_lockCount == 0 && _inputTranslator) { + if (_dragging && !_inputTranslator->isMousePressed()) { + CMouseButtonUpMsg upMsg(_mousePos, MK_LBUTTON); + handleMessage(upMsg); + } + + _buttonDown = _inputTranslator->isMousePressed(); + _singleton = true; + } +} + +void CInputHandler::handleMessage(CMessage &msg, bool respectLock) { + if (!respectLock || _lockCount <= 0) { + if (_gameManager->_gameState._mode == GSMODE_INTERACTIVE) { + processMessage(&msg); + } else if (!msg.isMouseMsg()) { + g_vm->_filesManager->loadDrive(); + } + } +} + +void CInputHandler::processMessage(CMessage *msg) { + const CMouseMsg *mouseMsg = dynamic_cast<const CMouseMsg *>(msg); + _singleton = false; + dispatchMessage(msg); + + if (_singleton) { + _singleton = false; + } else if (mouseMsg) { + // Keep the game state mouse position up to date + if (_mousePos != mouseMsg->_mousePos) { + _mousePos = mouseMsg->_mousePos; + _gameManager->_gameState.setMousePos(mouseMsg->_mousePos); + } + + // Set flag for whether a mouse button is currently being pressed + if (mouseMsg->isButtonDownMsg()) + _buttonDown = true; + else if (mouseMsg->isButtonUpMsg()) + _buttonDown = false; + + // Drag events generation + if (_dragging) { + if (mouseMsg->isMouseMoveMsg()) { + if (_dragItem) { + CMouseDragMoveMsg moveMsg(_mousePos); + moveMsg.execute(_dragItem); + } + } else { + if (mouseMsg->isButtonUpMsg() && _dragItem) { + // Mouse drag ended + CGameObject *target = dragEnd(_mousePos, _dragItem); + CMouseDragEndMsg endMsg(_mousePos, target); + endMsg.execute(_dragItem); + } + + _dragging = false; + _dragItem = nullptr; + } + } else if (_buttonDown) { + if (!mouseMsg->isMouseMoveMsg()) { + // Save where the drag movement started from + _dragStartPos = _mousePos; + } else { + Point delta = mouseMsg->_mousePos - _dragStartPos; + int distance = (int)sqrt(double(delta.x * delta.x + delta.y * delta.y)); + + if (distance > 4) { + // We've moved far enough with the mouse button held down + // to trigger an official dragging operation + CMouseDragStartMsg startMsg(_dragStartPos); + dispatchMessage(&startMsg); + + // Set the drag item, if any, that a handler will have set on the message + _dragItem = startMsg._dragItem; + _gameManager->_dragItem = startMsg._dragItem; + + if (_dragItem) { + CMouseDragMoveMsg moveMsg(_dragStartPos); + dispatchMessage(&moveMsg); + } + + _dragging = true; + } + } + } + } +} + +void CInputHandler::dispatchMessage(CMessage *msg) { + CPetControl *pet = _gameManager->_project->getPetControl(); + if (!pet || !msg->execute(pet, nullptr, MSGFLAG_BREAK_IF_HANDLED)) { + CViewItem *view = _gameManager->getView(); + msg->execute(view); + } +} + +CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) { + CViewItem *view = _gameManager->getView(); + if (!view) + return nullptr; + + // Scan through the view items to find the item being dropped on + CGameObject *target = nullptr; + for (CTreeItem *treeItem = view->scan(view); treeItem; treeItem = treeItem->scan(view)) { + CGameObject *gameObject = static_cast<CGameObject *>(treeItem); + if (gameObject && gameObject != dragItem) { + if (gameObject->checkPoint(pt)) + target = gameObject; + } + } + + if (target) { + // Check if the cursor is on the PET. If so, pass to the PET + // to see what specific element the drag ended on + CProjectItem *project = view->getRoot(); + if (project) { + CPetControl *petControl = project->getPetControl(); + if (petControl && petControl->contains(pt)) { + target = petControl->dragEnd(pt); + if (!target) + target = petControl; + } + } + } + + return target; +} + +} // End of namespace Titanic diff --git a/engines/titanic/input_handler.h b/engines/titanic/input_handler.h new file mode 100644 index 0000000000..7244ddc050 --- /dev/null +++ b/engines/titanic/input_handler.h @@ -0,0 +1,83 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_INPUT_HANDLER_H +#define TITANIC_INPUT_HANDLER_H + +#include "titanic/support/rect.h" +#include "titanic/input_translator.h" +#include "titanic/core/tree_item.h" + +namespace Titanic { + +class CGameManager; + +class CInputHandler { +private: + /** + * Process and dispatch a passed message + */ + void processMessage(CMessage *msg); + + /** + * Dispatches a message to the project + */ + void dispatchMessage(CMessage *msg); + + /** + * Called when a drag operation has ended + */ + CGameObject *dragEnd(const Point &pt, CTreeItem *dragItem); +public: + CGameManager *_gameManager; + CInputTranslator *_inputTranslator; + bool _dragging; + bool _buttonDown; + CTreeItem *_dragItem; + Point _dragStartPos; + Point _mousePos; + int _lockCount; + bool _singleton; +public: + CInputHandler(CGameManager *owner); + + void setTranslator(CInputTranslator *translator); + + /** + * Increment the lock count + */ + void incLockCount(); + + /** + * Decrement the lock count on the input handler + */ + void decLockCount(); + + /** + * Handles a genereated mouse message + */ + void handleMessage(CMessage &msg, bool respectLock = true); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_INPUT_HANDLER_H */ diff --git a/engines/titanic/input_translator.cpp b/engines/titanic/input_translator.cpp new file mode 100644 index 0000000000..ce272d152c --- /dev/null +++ b/engines/titanic/input_translator.cpp @@ -0,0 +1,114 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/input_handler.h" +#include "titanic/input_translator.h" +#include "titanic/events.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CInputTranslator::CInputTranslator(CInputHandler *inputHandler) : + _inputHandler(inputHandler) { + inputHandler->setTranslator(this); +} + +int CInputTranslator::getButtons(int special) const { + int buttons = 0; + if (special & MK_LBUTTON) + buttons |= MB_LEFT; + if (special & MK_MBUTTON) + buttons |= MB_MIDDLE; + if (special & MK_RBUTTON) + buttons |= MB_RIGHT; + + return buttons; +} + +void CInputTranslator::mouseMove(int special, const Point &pt) { + CMouseMoveMsg msg(pt, getButtons(special)); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::leftButtonDown(int special, const Point &pt) { + CMouseButtonDownMsg msg(pt, MB_LEFT); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::leftButtonUp(int special, const Point &pt) { + CMouseButtonUpMsg msg(pt, MB_LEFT); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::leftButtonDoubleClick(int special, const Point &pt) { + CMouseDoubleClickMsg msg(pt, MB_LEFT); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::middleButtonDown(int special, const Point &pt) { + CMouseButtonDownMsg msg(pt, MB_MIDDLE); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::middleButtonUp(int special, const Point &pt) { + CMouseButtonUpMsg msg(pt, MB_MIDDLE); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::middleButtonDoubleClick(int special, const Point &pt) { + CMouseDoubleClickMsg msg(pt, MB_MIDDLE); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::rightButtonDown(int special, const Point &pt) { + CMouseButtonDownMsg msg(pt, MB_RIGHT); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::rightButtonUp(int special, const Point &pt) { + CMouseButtonUpMsg msg(pt, MB_RIGHT); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::rightButtonDoubleClick(int special, const Point &pt) { + CMouseDoubleClickMsg msg(pt, MB_RIGHT); + _inputHandler->handleMessage(msg); +} + +void CInputTranslator::keyDown(const Common::KeyState &keyState) { + if (keyState.keycode >= Common::KEYCODE_F1 && keyState.keycode <= Common::KEYCODE_F5) { + CVirtualKeyCharMsg msg(keyState); + _inputHandler->handleMessage(msg); + } + + if (keyState.ascii <= 127) { + CKeyCharMsg msg(keyState.ascii); + _inputHandler->handleMessage(msg); + } +} + +bool CInputTranslator::isMousePressed() const { + return g_vm->_window->getSpecialButtons() & (MK_LBUTTON | MK_RBUTTON | MK_MBUTTON); +} + +} // End of namespace Titanic diff --git a/engines/titanic/input_translator.h b/engines/titanic/input_translator.h new file mode 100644 index 0000000000..d92157bccc --- /dev/null +++ b/engines/titanic/input_translator.h @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_INPUT_TRANSLATOR_H +#define TITANIC_INPUT_TRANSLATOR_H + +#include "common/keyboard.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +class CInputHandler; + +class CInputTranslator { +private: + /** + * Converts the special buttons bitset into a buttons bitset + */ + int getButtons(int special) const; +public: + CInputHandler *_inputHandler; +public: + CInputTranslator(CInputHandler *inputHandler); + + void mouseMove(int special, const Point &pt); + void leftButtonDown(int special, const Point &pt); + void leftButtonUp(int special, const Point &pt); + void leftButtonDoubleClick(int special, const Point &pt); + void middleButtonDown(int special, const Point &pt); + void middleButtonUp(int special, const Point &pt); + void middleButtonDoubleClick(int special, const Point &pt); + void rightButtonDown(int special, const Point &pt); + void rightButtonUp(int special, const Point &pt); + void rightButtonDoubleClick(int special, const Point &pt); + void keyDown(const Common::KeyState &keyState); + + /** + * Returns true if any mouse button is currently pressed + */ + bool isMousePressed() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_INPUT_TRANSLATOR_H */ diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp new file mode 100644 index 0000000000..486bc417d7 --- /dev/null +++ b/engines/titanic/main_game_window.cpp @@ -0,0 +1,350 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/config-manager.h" +#include "titanic/titanic.h" +#include "titanic/continue_save_dialog.h" +#include "titanic/game_manager.h" +#include "titanic/game_view.h" +#include "titanic/main_game_window.h" +#include "titanic/messages/messages.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +CMainGameWindow::CMainGameWindow(TitanicEngine *vm): _vm(vm), + _specialButtons(0), _priorLeftDownTime(0), + _priorMiddleDownTime(0), _priorRightDownTime(0) { + _gameView = nullptr; + _gameManager = nullptr; + _project = nullptr; + _inputAllowed = false; + _image = nullptr; + _cursor = nullptr; + _pendingLoadSlot = -1; + + // Set the window as an event target + vm->_events->addTarget(this); +} + +CMainGameWindow::~CMainGameWindow() { +} + +bool CMainGameWindow::Create() { + Image image; + image.load("TITANIC"); + + // TODO: Stuff + return true; +} + +void CMainGameWindow::applicationStarting() { + // Set the video mode + CScreenManager *screenManager = CScreenManager::setCurrent(); + screenManager->setMode(640, 480, 16, 0, true); + + // Set up the game project, and get game slot + int saveSlot = getSavegameSlot(); + if (saveSlot == -2) + return; + + // Create game view and manager + _gameView = new CSTGameView(this); + _gameManager = new CGameManager(_project, _gameView, g_vm->_mixer); + _gameView->setGameManager(_gameManager); + + // Load either a new game or selected existing save + _project->loadGame(saveSlot); + _inputAllowed = true; + _gameManager->_gameState.setMode(GSMODE_INTERACTIVE); + + // TODO: Cursor/image + + // Generate starting messages for entering the view, node, and room. + // Note the old fields are nullptr, since there's no previous view/node/room + CViewItem *view = _gameManager->_gameState._gameLocation.getView(); + CEnterViewMsg enterViewMsg(nullptr, view); + enterViewMsg.execute(view, nullptr, MSGFLAG_SCAN); + + CNodeItem *node = view->findNode(); + CEnterNodeMsg enterNodeMsg(nullptr, node); + enterNodeMsg.execute(node, nullptr, MSGFLAG_SCAN); + + CRoomItem *room = view->findRoom(); + CEnterRoomMsg enterRoomMsg(nullptr, room); + enterRoomMsg.execute(room, nullptr, MSGFLAG_SCAN); + + _gameManager->initBounds(); +} + +int CMainGameWindow::getSavegameSlot() { + _project = new CProjectItem(); + _project->setFilename("starship.prj"); + + return selectSavegame(); +} + +int CMainGameWindow::selectSavegame() { + // If the user selected a savegame from the launcher, return it + if (ConfMan.hasKey("save_slot")) + return ConfMan.getInt("save_slot"); + + CContinueSaveDialog dialog; + bool hasSavegames = false; + + // Loop through save slots to find any existing save slots + for (int idx = 0; idx < MAX_SAVES; ++idx) { + CString saveName = g_vm->getSavegameName(idx); + if (!saveName.empty()) { + dialog.addSavegame(idx, saveName); + hasSavegames = true; + } + } + + // If there are savegames, show the select dialog and get a choice. + // If there aren't, return -1 to indicate starting a new game + return hasSavegames ? dialog.show() : -1; +} + +void CMainGameWindow::setActiveView(CViewItem *viewItem) { + _gameManager->_gameState._gameLocation.setView(viewItem); + + CResourceKey key; + if (viewItem->getResourceKey(&key)) { + // Create a surface based on the key + _gameView->createSurface(key); + } +} + +void CMainGameWindow::draw() { + if (_gameManager) { + if (!_gameView->_surface) { + CViewItem *view = _gameManager->getView(); + if (view) + setActiveView(view); + } + + CScreenManager *scrManager = CScreenManager::setCurrent(); + scrManager->clearSurface(SURFACE_BACKBUFFER, &_gameManager->_bounds); + + switch (_gameManager->_gameState._mode) { + case GSMODE_INTERACTIVE: + case GSMODE_CUTSCENE: + if (_gameManager->_gameState._petActive) + drawPet(scrManager); + + drawView(); + drawViewContents(scrManager); + scrManager->drawCursors(); + break; + + case GSMODE_5: + g_vm->_filesManager->debug(scrManager); + break; + + case GSMODE_PENDING_LOAD: + // Pending savegame to load + _gameManager->_gameState.setMode(GSMODE_INTERACTIVE); + _vm->_window->_project->loadGame(_pendingLoadSlot); + break; + + default: + break; + } + } +} + +void CMainGameWindow::drawPet(CScreenManager *screenManager) { + if (_gameView && _gameView->_surface) { + CPetControl *petControl = _gameManager->_project->getPetControl(); + if (petControl) + petControl->draw(screenManager); + } +} + +void CMainGameWindow::drawView() { + if (_gameView->_surface) + _gameView->drawView(); +} + +void CMainGameWindow::drawViewContents(CScreenManager *screenManager) { + // Get a reference to the reference, validating that it's present + if (!screenManager) + return; + CViewItem *view = _gameManager->getView(); + if (!view) + return; + CNodeItem *node = view->findNode(); + if (!node) + return; + CRoomItem *room = node->findRoom(); + if (!room) + return; + + double xVal = 0.0, yVal = 0.0; + room->calcNodePosition(node->_nodePos, xVal, yVal); + + // Iterate through drawing all the items in the scene except any item + // that's currently being dragged + for (CTreeItem *treeItem = view; treeItem; treeItem = treeItem->scan(view)) { + if (treeItem != _gameManager->_dragItem) + treeItem->draw(screenManager); + } + + // Finally draw the drag item if there is one + if (_gameManager->_dragItem) + _gameManager->_dragItem->draw(screenManager); +} + +void CMainGameWindow::mouseChanged() { + if (_gameManager->_gameState._mode != GSMODE_5) + _gameManager->update(); +} + +void CMainGameWindow::loadGame(int slotId) { + _pendingLoadSlot = slotId; + _gameManager->_gameState.setMode(GSMODE_PENDING_LOAD); +} + +void CMainGameWindow::onIdle() { + if (!_inputAllowed) + return; + CGameManager *gameManager = _gameManager; + if (!gameManager) + return; + + // Let the game manager perform any game updates + gameManager->update(); + + if (gameManager->_gameState._quitGame) { + // Game needs to shut down + _vm->quitGame(); + } +} + +#define HANDLE_MESSAGE(METHOD) if (_inputAllowed) { \ + _gameManager->_inputTranslator.METHOD(_specialButtons, mousePos); \ + mouseChanged(); \ + } + + +void CMainGameWindow::mouseMove(const Point &mousePos) { + HANDLE_MESSAGE(mouseMove) +} + +void CMainGameWindow::leftButtonDown(const Point &mousePos) { + _specialButtons |= MK_LBUTTON; + + if ((_vm->_events->getTicksCount() - _priorLeftDownTime) < DOUBLE_CLICK_TIME) { + _priorLeftDownTime = 0; + leftButtonDoubleClick(mousePos); + } else { + _priorLeftDownTime = _vm->_events->getTicksCount(); + HANDLE_MESSAGE(leftButtonDown) + } +} + +void CMainGameWindow::leftButtonUp(const Point &mousePos) { + _specialButtons &= ~MK_LBUTTON; + HANDLE_MESSAGE(leftButtonUp) +} + +void CMainGameWindow::leftButtonDoubleClick(const Point &mousePos) { + HANDLE_MESSAGE(leftButtonDoubleClick) +} + +void CMainGameWindow::middleButtonDown(const Point &mousePos) { + _specialButtons |= MK_MBUTTON; + + if ((_vm->_events->getTicksCount() - _priorMiddleDownTime) < DOUBLE_CLICK_TIME) { + _priorMiddleDownTime = 0; + middleButtonDoubleClick(mousePos); + } else { + _priorMiddleDownTime = _vm->_events->getTicksCount(); + HANDLE_MESSAGE(middleButtonDown) + } +} + +void CMainGameWindow::middleButtonUp(const Point &mousePos) { + _specialButtons &= ~MK_MBUTTON; + HANDLE_MESSAGE(middleButtonUp) +} + +void CMainGameWindow::middleButtonDoubleClick(const Point &mousePos) { + HANDLE_MESSAGE(middleButtonDoubleClick) +} + +void CMainGameWindow::rightButtonDown(const Point &mousePos) { + _specialButtons |= MK_RBUTTON; + + if ((_vm->_events->getTicksCount() - _priorRightDownTime) < DOUBLE_CLICK_TIME) { + _priorRightDownTime = 0; + rightButtonDoubleClick(mousePos); + } else { + _priorRightDownTime = _vm->_events->getTicksCount(); + HANDLE_MESSAGE(rightButtonDown) + } +} + +void CMainGameWindow::rightButtonUp(const Point &mousePos) { + _specialButtons &= ~MK_RBUTTON; + HANDLE_MESSAGE(rightButtonUp) +} + +void CMainGameWindow::rightButtonDoubleClick(const Point &mousePos) { + HANDLE_MESSAGE(rightButtonDoubleClick) +} + +void CMainGameWindow::charPress(char c) { + +} + +void CMainGameWindow::keyDown(Common::KeyState keyState) { + handleKbdSpecial(keyState); + + if (keyState.keycode == Common::KEYCODE_d && (keyState.flags & Common::KBD_CTRL)) { + // Attach to the debugger + _vm->_debugger->attach(); + _vm->_debugger->onFrame(); + } + + if (_inputAllowed) + _gameManager->_inputTranslator.keyDown(keyState); +} + +void CMainGameWindow::keyUp(Common::KeyState keyState) { + handleKbdSpecial(keyState); +} + +void CMainGameWindow::handleKbdSpecial(Common::KeyState keyState) { + if (keyState.flags & Common::KBD_CTRL) + _specialButtons |= MK_CONTROL; + else + _specialButtons &= ~MK_CONTROL; + + if (keyState.flags & Common::KBD_SHIFT) + _specialButtons |= MK_SHIFT; + else + _specialButtons &= ~MK_SHIFT; +} + +} // End of namespace Titanic diff --git a/engines/titanic/main_game_window.h b/engines/titanic/main_game_window.h new file mode 100644 index 0000000000..82e24e250e --- /dev/null +++ b/engines/titanic/main_game_window.h @@ -0,0 +1,149 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAIN_GAME_WINDOW_H +#define TITANIC_MAIN_GAME_WINDOW_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "titanic/game_manager.h" +#include "titanic/game_view.h" +#include "titanic/support/image.h" +#include "titanic/core/project_item.h" +#include "titanic/events.h" + +namespace Titanic { + +class TitanicEngine; + +class CMainGameWindow : public CEventTarget { +private: + TitanicEngine *_vm; + int _pendingLoadSlot; + uint _specialButtons; + uint32 _priorFrameTime; + uint32 _priorLeftDownTime; + uint32 _priorMiddleDownTime; + uint32 _priorRightDownTime; +private: + /** + * Checks for the presence of any savegames and, if present, + * lets the user pick one to resume + */ + int getSavegameSlot(); + + /** + * Creates the game "project" and determine a game save slot + * to use + */ + int selectSavegame(); + + /** + * Used for drawing the PET fullscreen? maybe + */ + void drawPet(CScreenManager *screenManager); + + /** + * Draws the background for the view + */ + void drawView(); + + /** + * Draws all the items within the view + */ + void drawViewContents(CScreenManager *screenManager); + + void leftButtonDoubleClick(const Point &mousePos); + void middleButtonDoubleClick(const Point &mousePos); + void rightButtonDoubleClick(const Point &mousePos); + void charPress(char c); + void handleKbdSpecial(Common::KeyState keyState); +public: + CGameView *_gameView; + CGameManager *_gameManager; + CProjectItem *_project; + bool _inputAllowed; + Image *_image; + void *_cursor; +public: + CMainGameWindow(TitanicEngine *vm); + virtual ~CMainGameWindow(); + + /** + * Called to handle any regular updates the game requires + */ + void onIdle(); + + virtual void mouseMove(const Point &mousePos); + virtual void leftButtonDown(const Point &mousePos); + virtual void leftButtonUp(const Point &mousePos); + virtual void middleButtonDown(const Point &mousePos); + virtual void middleButtonUp(const Point &mousePos); + virtual void rightButtonDown(const Point &mousePos); + virtual void rightButtonUp(const Point &mousePos); + virtual void keyDown(Common::KeyState keyState); + virtual void keyUp(Common::KeyState keyState); + + /** + * Creates the window + */ + bool Create(); + + /** + * Called when the application starts + */ + void applicationStarting(); + + /** + * Sets the view to be shown + */ + void setActiveView(CViewItem *viewItem); + + /** + * Main draw method for the window + */ + void draw(); + + /** + * Called by the event handler when a mouse event has been generated + */ + void mouseChanged(); + + /** + * Schedules a savegame to be loaded + */ + void loadGame(int slotId); + + /* + * Return whether a given special key is currently pressed + */ + bool isSpecialPressed(SpecialButtons btn) const { return _specialButtons; } + + /** + * Returns the bitset of the currently pressed special buttons + */ + uint getSpecialButtons() const { return _specialButtons; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAIN_GAME_WINDOW_H */ diff --git a/engines/titanic/messages/auto_sound_event.cpp b/engines/titanic/messages/auto_sound_event.cpp new file mode 100644 index 0000000000..bc2cd7d074 --- /dev/null +++ b/engines/titanic/messages/auto_sound_event.cpp @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/messages/auto_sound_event.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAutoSoundEvent, CGameObject) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + +CAutoSoundEvent::CAutoSoundEvent() : CGameObject(), _value1(0), _value2(0xFFFFFF) { +} + +void CAutoSoundEvent::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CAutoSoundEvent::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +bool CAutoSoundEvent::FrameMsg(CFrameMsg *msg) { + if (_value1 >= 0) + _value1 = (_value1 + 1) & _value2; + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/messages/auto_sound_event.h b/engines/titanic/messages/auto_sound_event.h new file mode 100644 index 0000000000..d88976708e --- /dev/null +++ b/engines/titanic/messages/auto_sound_event.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AUTO_SOUND_EVENT_H +#define TITANIC_AUTO_SOUND_EVENT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CAutoSoundEvent : public CGameObject { + DECLARE_MESSAGE_MAP; + bool FrameMsg(CFrameMsg *msg); +public: + int _value1; + int _value2; +public: + CLASSDEF; + CAutoSoundEvent(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AUTO_SOUND_EVENT_H */ diff --git a/engines/titanic/messages/bilge_auto_sound_event.cpp b/engines/titanic/messages/bilge_auto_sound_event.cpp new file mode 100644 index 0000000000..fa87b4b79c --- /dev/null +++ b/engines/titanic/messages/bilge_auto_sound_event.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/messages/bilge_auto_sound_event.h" + +namespace Titanic { + +void CBilgeAutoSoundEvent::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CAutoSoundEvent::save(file, indent); +} + +void CBilgeAutoSoundEvent::load(SimpleFile *file) { + file->readNumber(); + CAutoSoundEvent::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/messages/bilge_auto_sound_event.h b/engines/titanic/messages/bilge_auto_sound_event.h new file mode 100644 index 0000000000..9a7fbd6261 --- /dev/null +++ b/engines/titanic/messages/bilge_auto_sound_event.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BILGE_AUTO_SOUND_EVENT_H +#define TITANIC_BILGE_AUTO_SOUND_EVENT_H + +#include "titanic/messages/auto_sound_event.h" + +namespace Titanic { + +class CBilgeAutoSoundEvent : public CAutoSoundEvent { +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BILGE_AUTO_SOUND_EVENT_H */ diff --git a/engines/titanic/messages/bilge_dispensor_event.cpp b/engines/titanic/messages/bilge_dispensor_event.cpp new file mode 100644 index 0000000000..043ffe75d3 --- /dev/null +++ b/engines/titanic/messages/bilge_dispensor_event.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/messages/bilge_dispensor_event.h" + +namespace Titanic { + +void CBilgeDispensorEvent::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CAutoSoundEvent::save(file, indent); +} + +void CBilgeDispensorEvent::load(SimpleFile *file) { + file->readNumber(); + CAutoSoundEvent::load(file); +} + +bool CBilgeDispensorEvent::EnterRoomMsg(CEnterRoomMsg *msg) { + _value1 = 0; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/messages/bilge_dispensor_event.h b/engines/titanic/messages/bilge_dispensor_event.h new file mode 100644 index 0000000000..96ef92a54e --- /dev/null +++ b/engines/titanic/messages/bilge_dispensor_event.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BILGE_DISPENSOR_EVENT_H +#define TITANIC_BILGE_DISPENSOR_EVENT_H + +#include "titanic/messages/auto_sound_event.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CBilgeDispensorEvent : public CAutoSoundEvent { + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BILGE_DISPENSOR_EVENT_H */ diff --git a/engines/titanic/messages/door_auto_sound_event.cpp b/engines/titanic/messages/door_auto_sound_event.cpp new file mode 100644 index 0000000000..b9cedae6de --- /dev/null +++ b/engines/titanic/messages/door_auto_sound_event.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/messages/door_auto_sound_event.h" + +namespace Titanic { + +void CDoorAutoSoundEvent::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_fieldE0, indent); + + CAutoSoundEvent::save(file, indent); +} + +void CDoorAutoSoundEvent::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + _fieldDC = file->readNumber(); + _fieldE0 = file->readNumber(); + + CAutoSoundEvent::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/messages/door_auto_sound_event.h b/engines/titanic/messages/door_auto_sound_event.h new file mode 100644 index 0000000000..e6ea1b0f98 --- /dev/null +++ b/engines/titanic/messages/door_auto_sound_event.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DOOR_AUTO_SOUND_EVENT_H +#define TITANIC_DOOR_AUTO_SOUND_EVENT_H + +#include "titanic/messages/auto_sound_event.h" + +namespace Titanic { + +class CDoorAutoSoundEvent : public CAutoSoundEvent { +public: + CString _string1; + CString _string2; + int _fieldDC; + int _fieldE0; +public: + CLASSDEF; + CDoorAutoSoundEvent() : CAutoSoundEvent(), + _string1("z#44.wav"), _string2("z#43.wav"), _fieldDC(25), _fieldE0(25) { + } + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DOOR_AUTO_SOUND_EVENT_H */ diff --git a/engines/titanic/messages/messages.cpp b/engines/titanic/messages/messages.cpp new file mode 100644 index 0000000000..5f587c975d --- /dev/null +++ b/engines/titanic/messages/messages.cpp @@ -0,0 +1,166 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/core/game_object.h" +#include "titanic/core/message_target.h" +#include "titanic/core/tree_item.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CMessage::CMessage() : CSaveableObject() { +} + +void CMessage::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); +} + +void CMessage::load(SimpleFile *file) { + file->readNumber(); + CSaveableObject::load(file); +} + +bool CMessage::execute(CTreeItem *target, const ClassDef *classDef, int flags) { + // If no target was specified, then there's nothing to do + if (!target) + return false; + + bool result = false; + CTreeItem *item = target; + CTreeItem *nextItem = nullptr; + do { + if (flags & MSGFLAG_SCAN) + nextItem = item->scan(target); + + if (!classDef || item->isInstanceOf(classDef)) { + bool handled = perform(item); + + if (handled) { + result = true; + if (flags & MSGFLAG_BREAK_IF_HANDLED) + return true; + } + } + + item = nextItem; + } while (nextItem); + + return result; +} + +bool CMessage::execute(const CString &target, const ClassDef *classDef, int flags) { + // Scan for the target by name + CProjectItem *project = g_vm->_window->_project; + for (CTreeItem *treeItem = project; treeItem; treeItem = treeItem->scan(project)) { + if (!treeItem->getName().compareToIgnoreCase(target)) + return execute(treeItem, classDef, flags); + } + + return false; +} + +const MSGMAP_ENTRY *CMessage::findMapEntry(const CTreeItem *treeItem, const ClassDef *classDef) { + // Iterate through the class and any parent classes + for (const MSGMAP *msgMap = treeItem->getMessageMap(); msgMap->pFnGetBaseMap; + msgMap = msgMap->pFnGetBaseMap()) { + // Iterate through the map entries for this class + for (const MSGMAP_ENTRY *entry = msgMap->lpEntries; + entry->_class != nullptr; ++entry) { + // Check if the class or any of it's ancesotrs is handled by this entry + for (const ClassDef *entryDef = entry->_class; entryDef; entryDef = entryDef->_parent) { + if (entryDef == classDef) + return entry; + } + } + } + + return nullptr; +} + +bool CMessage::perform(CTreeItem *treeItem) { + const MSGMAP_ENTRY *entry = findMapEntry(treeItem, getType()); + return entry && (*treeItem.*(entry->_fn))(this); +} + +bool CMessage::supports(const CTreeItem *treeItem, ClassDef *classDef) { + return findMapEntry(treeItem, classDef) != nullptr; +} + +bool CMessage::isMouseMsg() const { + return dynamic_cast<const CMouseMsg *>(this) != nullptr; +} + +bool CMessage::isButtonDownMsg() const { + return dynamic_cast<const CMouseButtonDownMsg *>(this) != nullptr; +} + +bool CMessage::isButtonUpMsg() const { + return dynamic_cast<const CMouseButtonUpMsg *>(this) != nullptr; +} + +bool CMessage::isMouseMoveMsg() const { + return dynamic_cast<const CMouseMoveMsg *>(this) != nullptr; +} + +bool CMessage::isDoubleClickMsg() const { + return dynamic_cast<const CMouseDoubleClickMsg *>(this) != nullptr; +} + +bool CMessage::isEnterRoomMsg() const { + return dynamic_cast<const CEnterRoomMsg *>(this) != nullptr; +} + +bool CMessage::isPreEnterRoomMsg() const { + return dynamic_cast<const CPreEnterRoomMsg *>(this) != nullptr; +} + +bool CMessage::isleaveRoomMsg() const { + return dynamic_cast<const CLeaveRoomMsg *>(this) != nullptr; +} + +bool CMessage::isEnterNodeMsg() const { + return dynamic_cast<const CEnterNodeMsg *>(this) != nullptr; +} + +bool CMessage::isPreEnterNodeMsg() const { + return dynamic_cast<const CPreEnterNodeMsg *>(this) != nullptr; +} + +bool CMessage::isLeaveNodeMsg() const { + return dynamic_cast<const CLeaveNodeMsg *>(this) != nullptr; +} + +bool CMessage::isEnterViewMsg() const { + return dynamic_cast<const CEnterViewMsg *>(this) != nullptr; +} + +bool CMessage::isPreEnterViewMsg() const { + return dynamic_cast<const CPreEnterViewMsg *>(this) != nullptr; +} + +bool CMessage::isLeaveViewMsg() const { + return dynamic_cast<const CLeaveViewMsg *>(this) != nullptr; +} + +} // End of namespace Titanic diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h new file mode 100644 index 0000000000..c1d962f656 --- /dev/null +++ b/engines/titanic/messages/messages.h @@ -0,0 +1,363 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MESSAGES_H +#define TITANIC_MESSAGES_H + +#include "common/keyboard.h" +#include "titanic/core/saveable_object.h" +#include "titanic/core/tree_item.h" + +namespace Titanic { + +enum MessageFlag { + MSGFLAG_SCAN = 1, + MSGFLAG_BREAK_IF_HANDLED = 2, + MSGFLAG_CLASS_DEF = 4 +}; + +#define MESSAGE0(NAME) \ + class NAME: public CMessage { \ + public: NAME() : CMessage() {} \ + CLASSDEF; \ + static bool isSupportedBy(const CTreeItem *item) { \ + return supports(item, _type); } \ +} +#define MESSAGE1(NAME, F1, N1, V1) \ + class NAME: public CMessage { \ + public: F1 _##N1; \ + NAME() : CMessage(), _##N1(V1) {} \ + NAME(F1 N1) : CMessage(), _##N1(N1) {} \ + CLASSDEF; \ + static bool isSupportedBy(const CTreeItem *item) { \ + return supports(item, _type); } \ +} +#define MESSAGE2(NAME, F1, N1, V1, F2, N2, V2) \ + class NAME: public CMessage { \ + public: F1 _##N1; F2 _##N2; \ + NAME() : CMessage(), _##N1(V1), _##N2(V2) {} \ + NAME(F1 N1, F2 N2) : CMessage(), _##N1(N1), _##N2(N2) {} \ + CLASSDEF; \ + static bool isSupportedBy(const CTreeItem *item) { \ + return supports(item, _type); } \ +} +#define MESSAGE3(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3) \ + class NAME: public CMessage { \ + public: F1 _##N1; F2 _##N2; F3 _##N3; \ + NAME() : CMessage(), _##N1(V1), _##N2(V2), _##N3(V3) {} \ + NAME(F1 N1, F2 N2, F3 N3) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3) {} \ + CLASSDEF; \ + static bool isSupportedBy(const CTreeItem *item) { \ + return supports(item, _type); } \ +} +#define MESSAGE4(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3, F4, N4, V4) \ + class NAME: public CMessage { \ + public: F1 _##N1; F2 _##N2; F3 _##N3; F4 _##N4; \ + NAME() : CMessage(), _##N1(V1), _##N2(V2), _##N3(V3), _##N4(V4) {} \ + NAME(F1 N1, F2 N2, F3 N3, F4 N4) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3), _##N4(N4) {} \ + CLASSDEF; \ + static bool isSupportedBy(const CTreeItem *item) { \ + return supports(item, _type); } \ +} + +class CCarry; +class CCharacter; +class CGameObject; +class CRoomItem; +class CNodeItem; +class CViewItem; +class CMusicPlayer; + +class CMessage : public CSaveableObject { +private: + /** + * Find a map entry that supports the given class + */ + static const MSGMAP_ENTRY *findMapEntry(const CTreeItem *treeItem, const ClassDef *classDef); +public: + CLASSDEF; + CMessage(); + + /** + * Executes the message, passing it on to the designated target, + * and optionally it's children + */ + bool execute(CTreeItem *target, const ClassDef *classDef = nullptr, + int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED); + + /** + * Executes the message, passing it on to the designated target, + * and optionally it's children + */ + bool execute(const CString &target, const ClassDef *classDef = nullptr, + int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED); + + /** + * Makes the passed item execute the message + */ + virtual bool perform(CTreeItem *treeItem); + + /** + * Returns true if the passed item supports the specified message class + */ + static bool supports(const CTreeItem *treeItem, ClassDef *classDef); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + virtual bool isMouseMsg() const; + virtual bool isButtonDownMsg() const; + virtual bool isButtonUpMsg() const; + virtual bool isMouseMoveMsg() const; + virtual bool isDoubleClickMsg() const; + virtual bool isEnterRoomMsg() const; + virtual bool isPreEnterRoomMsg() const; + virtual bool isleaveRoomMsg() const; + virtual bool isEnterNodeMsg() const; + virtual bool isPreEnterNodeMsg() const; + virtual bool isLeaveNodeMsg() const; + virtual bool isEnterViewMsg() const; + virtual bool isPreEnterViewMsg() const; + virtual bool isLeaveViewMsg() const; +}; + +class CEditControlMsg : public CMessage { +public: + int _field4; + int _field8; + CString _string1; + int _field18; + int _field1C; + int _field20; +public: + CLASSDEF; + CEditControlMsg() : _field4(0), _field8(0), _field18(0), + _field1C(0), _field20(0) {} + + static bool isSupportedBy(const CTreeItem *item) { + return CMessage::supports(item, _type); + } +}; + +class CLightsMsg : public CMessage { +public: + int _field4; + int _field8; + int _fieldC; + int _field10; +public: + CLASSDEF; + CLightsMsg() : CMessage(), _field4(0), _field8(0), + _fieldC(0), _field10(0) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +MESSAGE1(CTimeMsg, uint, _ticks, 0); + +class CTimerMsg : public CTimeMsg { +public: + uint _timerCtr; + int _actionVal; + CString _action; +public: + CLASSDEF; + CTimerMsg() : CTimeMsg(), _timerCtr(0), _actionVal(0) {} + CTimerMsg(uint ticks, uint timerCtr, int actionVal, const CString &action) : + CTimeMsg(ticks), _timerCtr(timerCtr), _actionVal(actionVal), _action(action) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +MESSAGE1(CActMsg, CString, action, ""); +MESSAGE1(CActivationmsg, CString, value, ""); +MESSAGE1(CAddHeadPieceMsg, CString, value, "NULL"); +MESSAGE1(CAnimateMaitreDMsg, int, value, 0); +MESSAGE1(CArboretumGateMsg, int, value, 0); +MESSAGE0(CArmPickedUpFromTableMsg); +MESSAGE0(CBodyInBilgeRoomMsg); +MESSAGE1(CBowlStateChange, int, value, 0); +MESSAGE2(CCarryObjectArrivedMsg, CString, strValue, "", int, numValue, 0); +MESSAGE2(CChangeMusicMsg, CString, filename, "", int, flags, 0); +MESSAGE1(CChangeSeasonMsg, CString, season, "Summer"); +MESSAGE0(CCheckAllPossibleCodes); +MESSAGE2(CCheckChevCode, int, value1, 0, int, value2, 0); +MESSAGE1(CChildDragEndMsg, int, value, 0); +MESSAGE2(CChildDragMoveMsg, int, value1, 0, int, value2, 0); +MESSAGE2(CChildDragStartMsg, int, value1, 0, int, value2, 0); +MESSAGE0(CClearChevPanelBits); +MESSAGE0(CCorrectMusicPlayedMsg); +MESSAGE0(CCreateMusicPlayerMsg); +MESSAGE0(CCylinderHolderReadyMsg); +MESSAGE0(CDeactivationMsg); +MESSAGE1(CDeliverCCarryMsg, CString, value, ""); +MESSAGE0(CDisableMaitreDProdReceptor); +MESSAGE0(CDismissBotMsg); +MESSAGE0(CDoffNavHelmet); +MESSAGE0(CDonNavHelmet); +MESSAGE1(CDoorbotNeededInElevatorMsg, int, value, 0); +MESSAGE0(CDoorbotNeededInHomeMsg); +MESSAGE1(CDropObjectMsg, CCarry *, item, nullptr); +MESSAGE1(CDropZoneGotObjectMsg, int, value, 0); +MESSAGE1(CDropZoneLostObjectMsg, int, value, 0); +MESSAGE1(CEjectCylinderMsg, int, value, 0); +MESSAGE2(CPreEnterNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nullptr); +MESSAGE2(CPreEnterRoomMsg, CRoomItem *, oldRoom, nullptr, CRoomItem *, newRoom, nullptr); +MESSAGE2(CPreEnterViewMsg, CViewItem *, oldView, nullptr, CViewItem *, newView, nullptr); +MESSAGE2(CEnterNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nullptr); +MESSAGE2(CEnterRoomMsg, CRoomItem *, oldRoom, nullptr, CRoomItem *, newRoom, nullptr); +MESSAGE2(CEnterViewMsg, CViewItem *, oldView, nullptr, CViewItem *, newView, nullptr); +MESSAGE0(CErasePhonographCylinderMsg); +MESSAGE1(CFrameMsg, uint, ticks, 0); +MESSAGE2(CFreshenCookieMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CGetChevClassBits, int, value, 0); +MESSAGE1(CGetChevClassNum, int, value, 0); +MESSAGE2(CGetChevCodeFromRoomNameMsg, CString, strValue, "", int, numValue, 0); +MESSAGE1(CGetChevFloorBits, int, value, 0); +MESSAGE1(CGetChevFloorNum, int, value, 0); +MESSAGE1(CGetChevLiftBits, int, value, 0); +MESSAGE1(CGetChevLiftNum, int, value, 0); +MESSAGE1(CGetChevRoomBits, int, value, 0); +MESSAGE1(CGetChevRoomNum, int, value, 0); +MESSAGE2(CHoseConnectedMsg, int, value1, 1, int, value2, 0); +MESSAGE0(CInitializeAnimMsg); +MESSAGE1(CIsEarBowlPuzzleDone, int, value, 0); +MESSAGE3(CIsHookedOnMsg, Rect, rect, Rect(), bool, result, false, CString, string1, ""); +MESSAGE1(CIsParrotPresentMsg, bool, value, false); +MESSAGE1(CKeyCharMsg, int, key, 32); +MESSAGE2(CLeaveNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nullptr); +MESSAGE2(CLeaveRoomMsg, CRoomItem *, oldRoom, nullptr, CRoomItem *, newRoom, nullptr); +MESSAGE2(CLeaveViewMsg, CViewItem *, oldView, nullptr, CViewItem *, newView, nullptr); +MESSAGE2(CLemonFallsFromTreeMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CLoadSuccessMsg, int, ticks, 0); +MESSAGE1(CLockPhonographMsg, int, value, 0); +MESSAGE0(CMaitreDDefeatedMsg); +MESSAGE0(CMaitreDHappyMsg); +MESSAGE1(CMissiveOMatActionMsg, int, value, 0); +MESSAGE0(CMoveToStartPosMsg); +MESSAGE2(CMovieEndMsg, int, startFrame, 0, int, endFrame, 0); +MESSAGE2(CMovieFrameMsg, int, frameNumber, 0, int, value2, 0); +MESSAGE0(CMusicHasStartedMsg); +MESSAGE0(CMusicHasStoppedMsg); +MESSAGE0(CMusicSettingChangedMsg); +MESSAGE2(CNPCPlayAnimationMsg, const char *const *, names, nullptr, int, value2, 0); +MESSAGE1(CNPCPlayIdleAnimationMsg, const char *const *, names, 0); +MESSAGE3(CNPCPlayTalkingAnimationMsg, int, value1, 0, int, value2, 0, const char *const *, names, nullptr); +MESSAGE0(CNPCQueueIdleAnimMsg); +MESSAGE1(CNutPuzzleMsg, CString, value, ""); +MESSAGE1(COnSummonBotMsg, int, value, 0); +MESSAGE0(COpeningCreditsMsg); +MESSAGE1(CPanningAwayFromParrotMsg, int, value, 0); +MESSAGE2(CParrotSpeakMsg, CString, value1, "", CString, value2, ""); +MESSAGE2(CParrotTriesChickenMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CPhonographPlayMsg, int, value, 0); +MESSAGE0(CPhonographReadyToPlayMsg); +MESSAGE1(CPhonographRecordMsg, int, value, 0); +MESSAGE3(CPhonographStopMsg, int, value1, 0, int, value2, 0, int, value3, 0); +MESSAGE2(CPlayRangeMsg, int, value1, 0, int, value2, 0); +MESSAGE2(CPlayerTriesRestaurantTableMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CPreSaveMsg, int, value, 0); +MESSAGE1(CProdMaitreDMsg, int, value, 0); +MESSAGE2(CPumpingMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CPutBotBackInHisBoxMsg, int, value, 0); +MESSAGE1(CPutParrotBackMsg, int, value, 0); +MESSAGE0(CPuzzleSolvedMsg); +MESSAGE3(CQueryCylinderHolderMsg, int, value1, 0, int, value2, 0, int, value3, 0); +MESSAGE1(CQueryCylinderMsg, CString, name, ""); +MESSAGE1(CQueryCylinderNameMsg, CString, name, ""); +MESSAGE3(CQueryCylinderTypeMsg, int, value1, 0, int, value2, 0, int, value3, 0); +MESSAGE1(CQueryMusicControlSettingMsg, int, value, 0); +MESSAGE1(CQueryPhonographState, int, value, 0); +MESSAGE0(CRecordOntoCylinderMsg); +MESSAGE0(CRemoveFromGameMsg); +MESSAGE0(CReplaceBowlAndNutsMsg); +MESSAGE1(CRestaurantMusicChanged, CString, value, ""); +MESSAGE2(CSendCCarryMsg, CString, strValue, "", int, numValue, 0); +MESSAGE1(CSenseWorkingMsg, CString, value, "Not Working"); +MESSAGE2(CServiceElevatorFloorChangeMsg, int, value1, 0, int, value2, 0); +MESSAGE0(CServiceElevatorFloorRequestMsg); +MESSAGE1(CServiceElevatorMsg, int, value, 4); +MESSAGE2(CSetChevButtonImageMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CSetChevClassBits, int, value, 0); +MESSAGE1(CSetChevFloorBits, int, value, 0); +MESSAGE1(CSetChevLiftBits, int, value, 0); +MESSAGE2(CSetChevPanelBitMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CSetChevPanelButtonsMsg, int, value, 0); +MESSAGE1(CSetChevRoomBits, int, value, 0); +MESSAGE1(CSetFrameMsg, int, frameNumber, 0); +MESSAGE0(CSetMusicControlsMsg); +MESSAGE2(CSetVarMsg, CString, varName, "", int, value, 0); +MESSAGE2(CSetVolumeMsg, int, volume, 70, int, secondsTransition, 0); +MESSAGE2(CShipSettingMsg, int, value, 0, CString, name, ""); +MESSAGE1(CShowTextMsg, CString, value, "NO TEXT INCLUDED!!!"); +MESSAGE2(CSignalObject, CString, strValue, "", int, numValue, 0); +MESSAGE2(CSpeechFallsFromTreeMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CStartMusicMsg, CMusicPlayer *, musicPlayer, (CMusicPlayer *)nullptr); +MESSAGE3(CStatusChangeMsg, int, oldStatus, 0, int, newStatus, 0, bool, success, false); +MESSAGE1(CStopMusicMsg, int, value, 0); +MESSAGE4(CSubAcceptCCarryMsg, CString, string1, "", int, value1, 0, int, value2, 0, CCarry *, item, nullptr); +MESSAGE0(CSubDeliverCCarryMsg); +MESSAGE0(CSubSendCCarryMsg); +MESSAGE0(CSUBTransition); +MESSAGE0(CSubTurnOffMsg); +MESSAGE0(CSubTurnOnMsg); +MESSAGE2(CSummonBotMsg, CString, strValue, "", int, numValue, 0); +MESSAGE1(CSummonBotQueryMsg, CString, npcName, ""); +MESSAGE1(CTakeHeadPieceMsg, CString, value, "NULL"); +MESSAGE2(CTextInputMsg, CString, input, "", CString, response, ""); +MESSAGE1(CTimeDilationMsg, int, value, 0); +MESSAGE0(CTitleSequenceEndedMsg); +MESSAGE0(CTransitMsg); +MESSAGE1(CTranslateObjectMsg, Point, delta, Point()); +MESSAGE3(CTransportMsg, CString, roomName, "", int, value1, 0, int, value2, 0); +MESSAGE1(CTriggerAutoMusicPlayerMsg, int, value, 0); +MESSAGE1(CTriggerNPCEvent, int, value, 0); +MESSAGE4(CTrueTalkGetAnimSetMsg, int, value1, 0, uint, index, 0, uint, startFrame, 0, uint, endFrame, 0); +MESSAGE2(CTrueTalkGetAssetDetailsMsg, CString, filename, "", int, numValue, 0); +MESSAGE2(CTrueTalkGetStateValueMsg, int, stateNum, 0, int, stateVal, -1000); +MESSAGE2(CTrueTalkNotifySpeechEndedMsg, int, value1, 0, int, dialogueId, 0); +MESSAGE3(CTrueTalkNotifySpeechStartedMsg, uint, soundId, 0, uint, dialogueId, 0, int, value, 0); +MESSAGE1(CTrueTalkQueueUpAnimSetMsg, int, value, 0); +MESSAGE0(CTrueTalkSelfQueueAnimSetMsg); +MESSAGE3(CTrueTalkTriggerActionMsg, int, action, 0, int, param1, 0, int, param2, 0); +MESSAGE0(CTurnOff); +MESSAGE0(CTurnOn); +MESSAGE1(CUse, CCarry *, item, nullptr); +MESSAGE1(CUseWithCharMsg, CCharacter *, character, nullptr); +MESSAGE1(CUseWithOtherMsg, CGameObject *, other, 0); +MESSAGE1(CVirtualKeyCharMsg, Common::KeyState, keyState, Common::KeyState()); +MESSAGE1(CVisibleMsg, bool, visible, true); + +} // End of namespace Titanic + +#endif /* TITANIC_MESSAGE_H */ diff --git a/engines/titanic/messages/mouse_messages.cpp b/engines/titanic/messages/mouse_messages.cpp new file mode 100644 index 0000000000..8ef7f38fd3 --- /dev/null +++ b/engines/titanic/messages/mouse_messages.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/messages/mouse_messages.h" +#include "titanic/support/mouse_cursor.h" +#include "titanic/support/screen_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +void CMouseButtonDownMsg::generate() { + CInputHandler &inputHandler = *CScreenManager::_screenManagerPtr->_inputHandler; + const Point &mousePos = inputHandler._mousePos; + + CMouseButtonDownMsg msg(mousePos, MB_LEFT); + inputHandler.handleMessage(msg, false); +} + +/*------------------------------------------------------------------------*/ + +void CMouseButtonUpMsg::generate() { + CInputHandler &inputHandler = *CScreenManager::_screenManagerPtr->_inputHandler; + const Point &mousePos = inputHandler._mousePos; + + CMouseButtonUpMsg msg(mousePos, MB_LEFT); + inputHandler.handleMessage(msg, false); +} + +} // End of namespace Titanic diff --git a/engines/titanic/messages/mouse_messages.h b/engines/titanic/messages/mouse_messages.h new file mode 100644 index 0000000000..d17bd51c78 --- /dev/null +++ b/engines/titanic/messages/mouse_messages.h @@ -0,0 +1,184 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOUSE_MESSAGES_H +#define TITANIC_MOUSE_MESSAGES_H + +#include "titanic/support/rect.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +enum MouseButton { MB_LEFT = 1, MB_MIDDLE = 2, MB_RIGHT = 4 }; + +class CMouseMsg : public CMessage { +public: + int _buttons; + Point _mousePos; +public: + CLASSDEF; + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } + + CMouseMsg() : _buttons(0) {} + CMouseMsg(const Point &pt, int buttons) : + _mousePos(pt), _buttons(buttons) {} +}; + +class CMouseMoveMsg : public CMouseMsg { +public: + CLASSDEF; + CMouseMoveMsg() : CMouseMsg() {} + CMouseMoveMsg(const Point &pt, int buttons) : CMouseMsg(pt, buttons) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +class CMouseButtonMsg : public CMouseMsg { +public: + int _field10; +public: + CLASSDEF; + CMouseButtonMsg() : CMouseMsg(), _field10(0) {} + CMouseButtonMsg(const Point &pt, int buttons) : CMouseMsg(pt, buttons) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +class CMouseButtonDownMsg : public CMouseButtonMsg { +public: + CLASSDEF; + CMouseButtonDownMsg() : CMouseButtonMsg() {} + CMouseButtonDownMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } + + /** + * Generate a dummy mouse down message at the current mouse position + */ + static void generate(); +}; + +class CMouseButtonUpMsg : public CMouseButtonMsg { +public: + CLASSDEF; + CMouseButtonUpMsg() : CMouseButtonMsg() {} + CMouseButtonUpMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } + + /** + * Generate a dummy mouse up message at the current mouse position + */ + static void generate(); +}; + +class CMouseDoubleClickMsg : public CMouseButtonMsg { +public: + CLASSDEF; + CMouseDoubleClickMsg() : CMouseButtonMsg() {} + CMouseDoubleClickMsg(const Point &pt, int buttons) : CMouseButtonMsg(pt, buttons) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +class CMouseDragMsg : public CMouseMsg { +public: + CLASSDEF; + CMouseDragMsg() : CMouseMsg() {} + CMouseDragMsg(const Point &pt) : CMouseMsg(pt, 0) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +class CMouseDragMoveMsg : public CMouseDragMsg { +public: + CLASSDEF; + CMouseDragMoveMsg() : CMouseDragMsg() {} + CMouseDragMoveMsg(const Point &pt) : CMouseDragMsg(pt) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +class CMouseDragStartMsg : public CMouseDragMsg { +public: + CTreeItem *_dragItem; + bool _handled; +public: + CLASSDEF; + CMouseDragStartMsg() : CMouseDragMsg(), _dragItem(nullptr), _handled(false) {} + CMouseDragStartMsg(const Point &pt) : CMouseDragMsg(pt), + _dragItem(nullptr), _handled(false) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +class CPassOnDragStartMsg : public CMessage { +public: + Point _mousePos; + int _value3; + int _value4; +public: + CLASSDEF; + CPassOnDragStartMsg() : CMessage() {} + CPassOnDragStartMsg(const Point &pt, int v3 = 0, int v4 = 0) : + CMessage(), _mousePos(pt), _value3(v3), _value4(v4) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +class CMouseDragEndMsg : public CMouseDragMsg { +public: + CGameObject *_dropTarget; +public: + CLASSDEF; + CMouseDragEndMsg() : CMouseDragMsg(), _dropTarget(nullptr) {} + CMouseDragEndMsg(const Point &pt, CGameObject *dropTarget = nullptr) : + CMouseDragMsg(pt), _dropTarget(dropTarget) {} + + static bool isSupportedBy(const CTreeItem *item) { + return supports(item, _type); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOUSE_MESSAGES_H */ diff --git a/engines/titanic/messages/pet_messages.h b/engines/titanic/messages/pet_messages.h new file mode 100644 index 0000000000..48e5bab64c --- /dev/null +++ b/engines/titanic/messages/pet_messages.h @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_MESSAGES_H +#define TITANIC_PET_MESSAGES_H + +#include "titanic/messages/messages.h" + +namespace Titanic { + +MESSAGE0(CPETDeliverMsg); +MESSAGE0(CPETGainedObjectMsg); +MESSAGE0(CPETHelmetOnOffMsg); +MESSAGE0(CPETKeyboardOnOffMsg); +MESSAGE0(CPETLostObjectMsg); +MESSAGE0(CPETObjectSelectedMsg); +MESSAGE1(CPETObjectStateMsg, int, value, 0); +MESSAGE0(CPETPhotoOnOffMsg); +MESSAGE1(CPETPlaySoundMsg, int, value, 0); +MESSAGE0(CPETReceiveMsg); +MESSAGE0(CPETSetStarDestinationMsg); +MESSAGE1(CPETStarFieldLockMsg, int, value, 0); +MESSAGE0(CPETStereoFieldOnOffMsg); +MESSAGE2(CPETTargetMsg, CString, name, "", int, numValue, -1); + +#define PET_MESSAGE(NAME) \ + class NAME: public CPETTargetMsg { \ + public: \ + NAME() : CPETTargetMsg() {} \ + NAME(const CString &name, int num) : CPETTargetMsg(name, num) {} \ + CLASSDEF; \ + static bool isSupportedBy(const CTreeItem *item) { \ + return supports(item, _type); \ + } \ +} + +PET_MESSAGE(CPETDownMsg); +PET_MESSAGE(CPETUpMsg); +PET_MESSAGE(CPETLeftMsg); +PET_MESSAGE(CPETRightMsg); +PET_MESSAGE(CPETActivateMsg); + +} // End of namespace Titanic + +#endif /* TITANIC_PET_MESSAGES_H */ diff --git a/engines/titanic/messages/service_elevator_door.cpp b/engines/titanic/messages/service_elevator_door.cpp new file mode 100644 index 0000000000..748790e4aa --- /dev/null +++ b/engines/titanic/messages/service_elevator_door.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/messages/service_elevator_door.h" + +namespace Titanic { + +CServiceElevatorDoor::CServiceElevatorDoor() : CDoorAutoSoundEvent() { + _string1 = "z#31.wav"; + _string2 = "z#32.wav"; +} + +void CServiceElevatorDoor::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string1, indent); + + CDoorAutoSoundEvent::save(file, indent); +} + +void CServiceElevatorDoor::load(SimpleFile *file) { + file->readNumber(); + _string2 = file->readString(); + _string1 = file->readString(); + + CDoorAutoSoundEvent::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/messages/service_elevator_door.h b/engines/titanic/messages/service_elevator_door.h new file mode 100644 index 0000000000..cc8da0917d --- /dev/null +++ b/engines/titanic/messages/service_elevator_door.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SERVICE_ELEVATOR_DOOR_H +#define TITANIC_SERVICE_ELEVATOR_DOOR_H + +#include "titanic/messages/door_auto_sound_event.h" + +namespace Titanic { + +class CServiceElevatorDoor : public CDoorAutoSoundEvent { +public: + CLASSDEF; + CServiceElevatorDoor(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SERVICE_ELEVATOR_DOOR_H */ diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk new file mode 100644 index 0000000000..5c041174a2 --- /dev/null +++ b/engines/titanic/module.mk @@ -0,0 +1,520 @@ +MODULE := engines/titanic + +MODULE_OBJS := \ + continue_save_dialog.o \ + debugger.o \ + detection.o \ + events.o \ + game_location.o \ + game_manager.o \ + game_state.o \ + game_view.o \ + input_handler.o \ + input_translator.o \ + main_game_window.o \ + room_flags.o \ + titanic.o \ + carry/auditory_centre.o \ + carry/arm.o \ + carry/bowl_ear.o \ + carry/brain.o \ + carry/bridge_piece.o \ + carry/carry.o \ + carry/carry_parrot.o \ + carry/central_core.o \ + carry/chicken.o \ + carry/crushed_tv.o \ + carry/ear.o \ + carry/eye.o \ + carry/feathers.o \ + carry/fruit.o \ + carry/glass.o \ + carry/hammer.o \ + carry/head_piece.o \ + carry/hose.o \ + carry/hose_end.o \ + carry/key.o \ + carry/liftbot_head.o \ + carry/long_stick.o \ + carry/magazine.o \ + carry/maitred_left_arm.o \ + carry/maitred_right_arm.o \ + carry/mouth.o \ + carry/napkin.o \ + carry/nose.o \ + carry/note.o \ + carry/parcel.o \ + carry/perch.o \ + carry/phonograph_cylinder.o \ + carry/phonograph_ear.o \ + carry/photograph.o \ + carry/plug_in.o \ + carry/speech_centre.o \ + carry/sweets.o \ + carry/vision_centre.o \ + core/background.o \ + core/click_responder.o \ + core/dont_save_file_item.o \ + core/drop_target.o \ + core/file_item.o \ + core/game_object.o \ + core/game_object_desc_item.o \ + core/link_item.o \ + core/list.o \ + core/mail_man.o \ + core/message_target.o \ + core/multi_drop_target.o \ + core/named_item.o \ + core/node_item.o \ + core/project_item.o \ + core/resource_key.o \ + core/room_item.o \ + core/saveable_object.o \ + core/static_image.o \ + core/turn_on_object.o \ + core/turn_on_play_sound.o \ + core/turn_on_turn_off.o \ + core/tree_item.o \ + core/view_item.o \ + game/announce.o \ + game/annoy_barbot.o \ + game/arb_background.o \ + game/arboretum_gate.o \ + game/auto_animate.o \ + game/bilge_succubus.o \ + game/bar_menu.o \ + game/bar_menu_button.o \ + game/bar_bell.o \ + game/belbot_get_light.o \ + game/bottom_of_well_monitor.o \ + game/bomb.o \ + game/bowl_unlocker.o \ + game/brain_slot.o \ + game/bridge_door.o \ + game/bridge_view.o \ + game/broken_pell_base.o \ + game/broken_pellerator.o \ + game/broken_pellerator_froz.o \ + game/call_pellerator.o \ + game/cage.o \ + game/captains_wheel.o \ + game/cdrom.o \ + game/cdrom_computer.o \ + game/cdrom_tray.o \ + game/cell_point_button.o \ + game/chev_code.o \ + game/chev_panel.o \ + game/chicken_cooler.o \ + game/chicken_dispensor.o \ + game/close_broken_pel.o \ + game/code_wheel.o \ + game/cookie.o \ + game/computer.o \ + game/computer_screen.o \ + game/credits.o \ + game/credits_button.o \ + game/dead_area.o \ + game/desk_click_responder.o \ + game/doorbot_elevator_handler.o \ + game/doorbot_home_handler.o \ + game/ear_sweet_bowl.o \ + game/eject_phonograph_button.o \ + game/elevator_action_area.o \ + game/emma_control.o \ + game/empty_nut_bowl.o \ + game/end_credit_text.o \ + game/end_credits.o \ + game/end_explode_ship.o \ + game/end_game_credits.o \ + game/end_sequence_control.o \ + game/hammer_dispensor.o \ + game/hammer_dispensor_button.o \ + game/fan.o \ + game/fan_control.o \ + game/fan_decrease.o \ + game/fan_increase.o \ + game/fan_noises.o \ + game/floor_indicator.o \ + game/games_console.o \ + game/get_lift_eye2.o \ + game/glass_smasher.o \ + game/hammer_clip.o \ + game/head_slot.o \ + game/head_smash_event.o \ + game/head_smash_lever.o \ + game/head_spinner.o \ + game/idle_summoner.o \ + game/leave_sec_class_state.o \ + game/lemon_dispensor.o \ + game/light.o \ + game/light_switch.o \ + game/little_lift_button.o \ + game/long_stick_dispenser.o \ + game/missiveomat.o \ + game/missiveomat_button.o \ + game/movie_tester.o \ + game/music_console_button.o \ + game/music_room_phonograph.o \ + game/music_room_stop_phonograph_button.o \ + game/music_system_lock.o \ + game/musical_instrument.o \ + game/nav_helmet.o \ + game/navigation_computer.o \ + game/no_nut_bowl.o \ + game/nose_holder.o \ + game/null_port_hole.o \ + game/nut_replacer.o \ + game/pet_disabler.o \ + game/phonograph.o \ + game/phonograph_lid.o \ + game/play_music_button.o \ + game/play_on_act.o \ + game/port_hole.o \ + game/record_phonograph_button.o \ + game/replacement_ear.o \ + game/reserved_table.o \ + game/restaurant_cylinder_holder.o \ + game/restaurant_phonograph.o \ + game/sauce_dispensor.o \ + game/search_point.o \ + game/season_background.o \ + game/season_barrel.o \ + game/seasonal_adjustment.o \ + game/service_elevator_window.o \ + game/ship_setting.o \ + game/ship_setting_button.o \ + game/show_cell_points.o \ + game/speech_dispensor.o \ + game/splash_animation.o \ + game/starling_puret.o \ + game/start_action.o \ + game/stop_phonograph_button.o \ + game/sub_glass.o \ + game/sub_wrapper.o \ + game/sweet_bowl.o \ + game/television.o \ + game/third_class_canal.o \ + game/tow_parrot_nav.o \ + game/throw_tv_down_well.o \ + game/titania_still_control.o \ + game/up_lighter.o \ + game/useless_lever.o \ + game/volume_control.o \ + game/wheel_button.o \ + game/wheel_hotspot.o \ + game/wheel_spin.o \ + game/wheel_spin_horn.o \ + game/gondolier/gondolier_base.o \ + game/gondolier/gondolier_chest.o \ + game/gondolier/gondolier_face.o \ + game/gondolier/gondolier_mixer.o \ + game/gondolier/gondolier_slider.o \ + game/maitred/maitred_arm_holder.o \ + game/maitred/maitred_body.o \ + game/maitred/maitred_legs.o \ + game/maitred/maitred_prod_receptor.o \ + game/parrot/parrot_lobby_controller.o \ + game/parrot/parrot_lobby_link_updater.o \ + game/parrot/parrot_lobby_object.o \ + game/parrot/parrot_lobby_view_object.o \ + game/parrot/parrot_loser.o \ + game/parrot/parrot_nut_bowl_actor.o \ + game/parrot/parrot_nut_eater.o \ + game/parrot/parrot_perch_holder.o \ + game/parrot/parrot_succubus.o \ + game/parrot/parrot_trigger.o \ + game/parrot/player_meets_parrot.o \ + game/pet/pet.o \ + game/pet/pet_class1.o \ + game/pet/pet_class2.o \ + game/pet/pet_class3.o \ + game/pet/pet_lift.o \ + game/pet/pet_monitor.o \ + game/pet/pet_pellerator.o \ + game/pet/pet_position.o \ + game/pet/pet_sentinal.o \ + game/pet/pet_sounds.o \ + game/pet/pet_transition.o \ + game/pet/pet_transport.o \ + game/pickup/pick_up.o \ + game/pickup/pick_up_bar_glass.o \ + game/pickup/pick_up_hose.o \ + game/pickup/pick_up_lemon.o \ + game/pickup/pick_up_speech_centre.o \ + game/pickup/pick_up_vis_centre.o \ + game/placeholder/bar_shelf_vis_centre.o \ + game/placeholder/place_holder_item.o \ + game/placeholder/lemon_on_bar.o \ + game/placeholder/tv_on_bar.o \ + game/transport/gondolier.o \ + game/transport/lift.o \ + game/transport/lift_indicator.o \ + game/transport/pellerator.o \ + game/transport/service_elevator.o \ + game/transport/transport.o \ + game/sgt/armchair.o \ + game/sgt/basin.o \ + game/sgt/bedfoot.o \ + game/sgt/bedhead.o \ + game/sgt/chest_of_drawers.o \ + game/sgt/desk.o \ + game/sgt/deskchair.o \ + game/sgt/drawer.o \ + game/sgt/sgt_doors.o \ + game/sgt/sgt_nav.o \ + game/sgt/sgt_navigation.o \ + game/sgt/sgt_restaurant_doors.o \ + game/sgt/sgt_state_control.o \ + game/sgt/sgt_state_room.o \ + game/sgt/sgt_tv.o \ + game/sgt/sgt_upper_doors_sound.o \ + game/sgt/toilet.o \ + game/sgt/vase.o \ + game/sgt/washstand.o \ + gfx/act_button.o \ + gfx/changes_season_button.o \ + gfx/chev_left_off.o \ + gfx/chev_left_on.o \ + gfx/chev_right_off.o \ + gfx/chev_right_on.o \ + gfx/chev_send_rec_switch.o \ + gfx/chev_switch.o \ + gfx/edit_control.o \ + gfx/elevator_button.o \ + gfx/get_from_succ.o \ + gfx/helmet_on_off.o \ + gfx/home_photo.o \ + gfx/icon_nav_action.o \ + gfx/icon_nav_butt.o \ + gfx/icon_nav_down.o \ + gfx/icon_nav_image.o \ + gfx/icon_nav_left.o \ + gfx/icon_nav_receive.o \ + gfx/icon_nav_right.o \ + gfx/icon_nav_send.o \ + gfx/icon_nav_up.o \ + gfx/keybrd_butt.o \ + gfx/move_object_button.o \ + gfx/music_control.o \ + gfx/music_slider.o \ + gfx/music_switch.o \ + gfx/send_to_succ.o \ + gfx/sgt_selector.o \ + gfx/slider_button.o \ + gfx/small_chev_left_off.o \ + gfx/small_chev_left_on.o \ + gfx/small_chev_right_off.o \ + gfx/small_chev_right_on.o \ + gfx/status_change_button.o \ + gfx/st_button.o \ + gfx/text_down.o \ + gfx/text_skrew.o \ + gfx/text_up.o \ + gfx/toggle_button.o \ + gfx/toggle_switch.o \ + messages/auto_sound_event.o \ + messages/bilge_auto_sound_event.o \ + messages/bilge_dispensor_event.o \ + messages/door_auto_sound_event.o \ + messages/messages.o \ + messages/mouse_messages.o \ + messages/service_elevator_door.o \ + moves/enter_bomb_room.o \ + moves/enter_bridge.o \ + moves/enter_exit_first_class_state.o \ + moves/enter_exit_mini_lift.o \ + moves/enter_exit_sec_class_mini_lift.o \ + moves/enter_exit_view.o \ + moves/enter_sec_class_state.o \ + moves/exit_arboretum.o \ + moves/exit_bridge.o \ + moves/exit_lift.o \ + moves/exit_pellerator.o \ + moves/exit_state_room.o \ + moves/exit_tiania.o \ + moves/move_player_in_parrot_room.o \ + moves/move_player_to_from.o \ + moves/move_player_to.o \ + moves/multi_move.o \ + moves/pan_from_pel.o \ + moves/restaurant_pan_handler.o \ + moves/restricted_move.o \ + moves/scraliontis_table.o \ + moves/trip_down_canal.o \ + npcs/barbot.o \ + npcs/bellbot.o \ + npcs/callbot.o \ + npcs/character.o \ + npcs/deskbot.o \ + npcs/doorbot.o \ + npcs/liftbot.o \ + npcs/maitre_d.o \ + npcs/mobile.o \ + npcs/parrot.o \ + npcs/robot_controller.o \ + npcs/starlings.o \ + npcs/succubus.o \ + npcs/summon_bots.o \ + npcs/titania.o \ + npcs/true_talk_npc.o \ + pet_control/pet_control.o \ + pet_control/pet_conversations.o \ + pet_control/pet_element.o \ + pet_control/pet_frame.o \ + pet_control/pet_gfx_element.o \ + pet_control/pet_inventory.o \ + pet_control/pet_inventory_glyphs.o \ + pet_control/pet_message.o \ + pet_control/pet_starfield.o \ + pet_control/pet_real_life.o \ + pet_control/pet_remote.o \ + pet_control/pet_remote_glyphs.o \ + pet_control/pet_rooms.o \ + pet_control/pet_rooms_glyphs.o \ + pet_control/pet_section.o \ + pet_control/pet_drag_chev.o \ + pet_control/pet_graphic2.o \ + pet_control/pet_graphic.o \ + pet_control/pet_glyphs.o \ + pet_control/pet_leaf.o \ + pet_control/pet_load.o \ + pet_control/pet_load_save.o \ + pet_control/pet_mode_off.o \ + pet_control/pet_mode_on.o \ + pet_control/pet_mode_panel.o \ + pet_control/pet_pannel1.o \ + pet_control/pet_pannel2.o \ + pet_control/pet_pannel3.o \ + pet_control/pet_quit.o \ + pet_control/pet_save.o \ + pet_control/pet_slider.o \ + pet_control/pet_sound.o \ + pet_control/pet_text.o \ + sound/auto_music_player.o \ + sound/auto_music_player_base.o \ + sound/auto_sound_player.o \ + sound/auto_sound_player_adsr.o \ + sound/background_sound_maker.o \ + sound/bird_song.o \ + sound/dome_from_top_of_well.o \ + sound/enter_view_toggles_other_music.o \ + sound/gondolier_song.o \ + sound/music_handler.o \ + sound/music_room.o \ + sound/music_player.o \ + sound/music_wave.o \ + sound/node_auto_sound_player.o \ + sound/proximity.o \ + sound/qmixer.o \ + sound/restricted_auto_music_player.o \ + sound/room_auto_sound_player.o \ + sound/room_trigger_auto_music_player.o \ + sound/season_noises.o \ + sound/seasonal_music_player.o \ + sound/sound.o \ + sound/sound_manager.o \ + sound/titania_speech.o \ + sound/trigger_auto_music_player.o \ + sound/view_auto_sound_player.o \ + sound/view_toggles_other_music.o \ + sound/water_lapping_sounds.o \ + sound/wave_file.o \ + star_control/star_control.o \ + star_control/base_star.o \ + star_control/dmatrix.o \ + star_control/dvector.o \ + star_control/fmatrix.o \ + star_control/fpoint.o \ + star_control/fvector.o \ + star_control/star_control_sub2.o \ + star_control/star_control_sub4.o \ + star_control/star_control_sub5.o \ + star_control/star_control_sub6.o \ + star_control/star_control_sub7.o \ + star_control/star_control_sub8.o \ + star_control/star_control_sub12.o \ + star_control/star_control_sub13.o \ + star_control/star_control_sub20.o \ + star_control/star_control_sub21.o \ + star_control/star_control_sub22.o \ + star_control/star_control_sub23.o \ + star_control/star_control_sub24.o \ + star_control/star_control_sub25.o \ + star_control/star_control_sub26.o \ + star_control/star_control_sub27.o \ + star_control/star_field.o \ + star_control/star_points1.o \ + star_control/star_points2.o \ + star_control/star_view.o \ + star_control/surface_area.o \ + star_control/surface_fader_base.o \ + star_control/surface_fader.o \ + support/avi_surface.o \ + support/direct_draw.o \ + support/direct_draw_surface.o \ + support/exe_resources.o \ + support/files_manager.o \ + support/font.o \ + support/image.o \ + support/image_decoders.o \ + support/mouse_cursor.o \ + support/movie.o \ + support/movie_clip.o \ + support/movie_event.o \ + support/movie_range_info.o \ + support/movie_manager.o \ + support/credit_text.o \ + support/rect.o \ + support/screen_manager.o \ + support/simple_file.o \ + support/string.o \ + support/text_cursor.o \ + support/time_event_info.o \ + support/video_surface.o \ + true_talk/barbot_script.o \ + true_talk/bellbot_script.o \ + true_talk/deskbot_script.o \ + true_talk/dialogue_file.o \ + true_talk/doorbot_script.o \ + true_talk/liftbot_script.o \ + true_talk/maitred_script.o \ + true_talk/parrot_script.o \ + true_talk/succubus_script.o \ + true_talk/title_engine.o \ + true_talk/script_handler.o \ + true_talk/script_support.o \ + true_talk/true_talk_manager.o \ + true_talk/tt_action.o \ + true_talk/tt_adj.o \ + true_talk/tt_concept.o \ + true_talk/tt_concept_node.o \ + true_talk/tt_hist.o \ + true_talk/tt_major_word.o \ + true_talk/tt_node.o \ + true_talk/tt_npc_script.o \ + true_talk/tt_parser.o \ + true_talk/tt_picture.o \ + true_talk/tt_pronoun.o \ + true_talk/tt_quotes.o \ + true_talk/tt_quotes_tree.o \ + true_talk/tt_response.o \ + true_talk/tt_room_script.o \ + true_talk/tt_script_base.o \ + true_talk/tt_scripts.o \ + true_talk/tt_sentence.o \ + true_talk/tt_sentence_node.o \ + true_talk/tt_string.o \ + true_talk/tt_string_node.o \ + true_talk/tt_synonym.o \ + true_talk/tt_talker.o \ + true_talk/tt_title_script.o \ + true_talk/tt_vocab.o \ + true_talk/tt_word.o + +# This module can be built as a plugin +ifeq ($(ENABLE_TITANIC), DYNAMIC_PLUGIN) +PLUGIN := 1 +endif + +# Include common rules +include $(srcdir)/rules.mk diff --git a/engines/titanic/moves/enter_bomb_room.cpp b/engines/titanic/moves/enter_bomb_room.cpp new file mode 100644 index 0000000000..55b838d026 --- /dev/null +++ b/engines/titanic/moves/enter_bomb_room.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/enter_bomb_room.h" + +namespace Titanic { + +CEnterBombRoom::CEnterBombRoom() : CMovePlayerTo(), _fieldC8(0) { +} + +void CEnterBombRoom::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMovePlayerTo::save(file, indent); +} + +void CEnterBombRoom::load(SimpleFile *file) { + file->readNumber(); + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/enter_bomb_room.h b/engines/titanic/moves/enter_bomb_room.h new file mode 100644 index 0000000000..7fe8287eae --- /dev/null +++ b/engines/titanic/moves/enter_bomb_room.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_BOMB_ROOM_H +#define TITANIC_ENTER_BOMB_ROOM_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CEnterBombRoom : public CMovePlayerTo { +protected: + int _fieldC8; +public: + CLASSDEF; + CEnterBombRoom(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_BOMB_ROOM_H */ diff --git a/engines/titanic/moves/enter_bridge.cpp b/engines/titanic/moves/enter_bridge.cpp new file mode 100644 index 0000000000..2600ee699f --- /dev/null +++ b/engines/titanic/moves/enter_bridge.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/enter_bridge.h" + +namespace Titanic { + +void CEnterBridge::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CEnterBridge::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +bool CEnterBridge::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CEnterBridge::handlEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/enter_bridge.h b/engines/titanic/moves/enter_bridge.h new file mode 100644 index 0000000000..a2410a6f1f --- /dev/null +++ b/engines/titanic/moves/enter_bridge.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_BRIDGE_H +#define TITANIC_ENTER_BRIDGE_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CEnterBridge : public CGameObject { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _value; +public: + CLASSDEF; + CEnterBridge() : CGameObject(), _value(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_BRIDGE_H */ diff --git a/engines/titanic/moves/enter_exit_first_class_state.cpp b/engines/titanic/moves/enter_exit_first_class_state.cpp new file mode 100644 index 0000000000..0e2c6c0b6c --- /dev/null +++ b/engines/titanic/moves/enter_exit_first_class_state.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/enter_exit_first_class_state.h" + +namespace Titanic { + +CString *CEnterExitFirstClassState::_v1; + +void CEnterExitFirstClassState::init() { + _v1 = new CString(); +} + +void CEnterExitFirstClassState::deinit() { + delete _v1; +} + +void CEnterExitFirstClassState::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(*_v1, indent); + CGameObject::save(file, indent); +} + +void CEnterExitFirstClassState::load(SimpleFile *file) { + file->readNumber(); + *_v1 = file->readString(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/enter_exit_first_class_state.h b/engines/titanic/moves/enter_exit_first_class_state.h new file mode 100644 index 0000000000..a08de07711 --- /dev/null +++ b/engines/titanic/moves/enter_exit_first_class_state.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_EXIT_FIRST_CLASS_STATE_H +#define TITANIC_ENTER_EXIT_FIRST_CLASS_STATE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CEnterExitFirstClassState : public CGameObject { +public: + static CString *_v1; + + /** + * Initialize static data + */ + static void init(); + + /** + * De-initialize static data + */ + static void deinit(); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_EXIT_FIRST_CLASS_STATE_H */ diff --git a/engines/titanic/moves/enter_exit_mini_lift.cpp b/engines/titanic/moves/enter_exit_mini_lift.cpp new file mode 100644 index 0000000000..eb56bdb3bd --- /dev/null +++ b/engines/titanic/moves/enter_exit_mini_lift.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/enter_exit_mini_lift.h" + +namespace Titanic { + +void CEnterExitMiniLift::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + + CSGTNavigation::save(file, indent); +} + +void CEnterExitMiniLift::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + + CSGTNavigation::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/enter_exit_mini_lift.h b/engines/titanic/moves/enter_exit_mini_lift.h new file mode 100644 index 0000000000..26f3dba8d4 --- /dev/null +++ b/engines/titanic/moves/enter_exit_mini_lift.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_EXIT_MINI_LIFT_H +#define TITANIC_ENTER_EXIT_MINI_LIFT_H + +#include "titanic/game/sgt/sgt_navigation.h" + +namespace Titanic { + +class CEnterExitMiniLift : public CSGTNavigation { +private: + int _fieldBC; + int _fieldC0; +public: + CLASSDEF; + CEnterExitMiniLift() : CSGTNavigation(), _fieldBC(0), _fieldC0(1) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_EXIT_MINI_LIFT_H */ diff --git a/engines/titanic/moves/enter_exit_sec_class_mini_lift.cpp b/engines/titanic/moves/enter_exit_sec_class_mini_lift.cpp new file mode 100644 index 0000000000..b571a255c5 --- /dev/null +++ b/engines/titanic/moves/enter_exit_sec_class_mini_lift.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/enter_exit_sec_class_mini_lift.h" + +namespace Titanic { + +CEnterExitSecClassMiniLiftStatics *CEnterExitSecClassMiniLift::_statics; + +void CEnterExitSecClassMiniLift::init() { + _statics = new CEnterExitSecClassMiniLiftStatics(); +} + +void CEnterExitSecClassMiniLift::deinit() { + delete _statics; +} + +void CEnterExitSecClassMiniLift::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_statics->_v1, indent); + file->writeNumberLine(_statics->_v2, indent); + file->writeNumberLine(_value, indent); + + CGameObject::save(file, indent); +} + +void CEnterExitSecClassMiniLift::load(SimpleFile *file) { + file->readNumber(); + _statics->_v1 = file->readString(); + _statics->_v2 = file->readNumber(); + _value = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/enter_exit_sec_class_mini_lift.h b/engines/titanic/moves/enter_exit_sec_class_mini_lift.h new file mode 100644 index 0000000000..10c7edca7d --- /dev/null +++ b/engines/titanic/moves/enter_exit_sec_class_mini_lift.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_EXIT_SEC_CLASS_MINI_LIFT_H +#define TITANIC_ENTER_EXIT_SEC_CLASS_MINI_LIFT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +struct CEnterExitSecClassMiniLiftStatics { + CString _v1; + int _v2; + + CEnterExitSecClassMiniLiftStatics() : _v2(1) {} +}; + +class CEnterExitSecClassMiniLift : public CGameObject { +private: + static CEnterExitSecClassMiniLiftStatics *_statics; + int _value; +public: + CLASSDEF; + CEnterExitSecClassMiniLift() : CGameObject(), _value(0) {} + static void init(); + static void deinit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_EXIT_SEC_CLASS_MINI_LIFT_H */ diff --git a/engines/titanic/moves/enter_exit_view.cpp b/engines/titanic/moves/enter_exit_view.cpp new file mode 100644 index 0000000000..825156acce --- /dev/null +++ b/engines/titanic/moves/enter_exit_view.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/enter_exit_view.h" + +namespace Titanic { + +CEnterExitView::CEnterExitView() : CGameObject(), _fieldBC(0), + _fieldC0(0), _fieldC4(0), _fieldC8(0), _fieldCC(0) { +} + +void CEnterExitView::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + + CGameObject::save(file, indent); +} + +void CEnterExitView::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/enter_exit_view.h b/engines/titanic/moves/enter_exit_view.h new file mode 100644 index 0000000000..4a3f1a967b --- /dev/null +++ b/engines/titanic/moves/enter_exit_view.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_EXIT_VIEW_H +#define TITANIC_ENTER_EXIT_VIEW_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CEnterExitView : public CGameObject { +public: + int _fieldBC; + int _fieldC0; + int _fieldC4; + int _fieldC8; + int _fieldCC; +public: + CLASSDEF; + CEnterExitView(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_EXIT_VIEW_H */ diff --git a/engines/titanic/moves/enter_sec_class_state.cpp b/engines/titanic/moves/enter_sec_class_state.cpp new file mode 100644 index 0000000000..dced724de7 --- /dev/null +++ b/engines/titanic/moves/enter_sec_class_state.cpp @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/enter_sec_class_state.h" + +namespace Titanic { + +void CEnterSecClassState::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value1, indent); + file->writeNumberLine(_value2, indent); + + CGameObject::save(file, indent); +} + +void CEnterSecClassState::load(SimpleFile *file) { + file->readNumber(); + _value1 = file->readNumber(); + _value2 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/enter_sec_class_state.h b/engines/titanic/moves/enter_sec_class_state.h new file mode 100644 index 0000000000..c3e3cabf20 --- /dev/null +++ b/engines/titanic/moves/enter_sec_class_state.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_SEC_CLASS_STATE_H +#define TITANIC_ENTER_SEC_CLASS_STATE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CEnterSecClassState : public CGameObject { +public: + int _value1, _value2; +public: + CLASSDEF; + CEnterSecClassState() : CGameObject(), _value1(0), _value2(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_SEC_CLASS_STATE_H */ diff --git a/engines/titanic/moves/exit_arboretum.cpp b/engines/titanic/moves/exit_arboretum.cpp new file mode 100644 index 0000000000..d606510c6e --- /dev/null +++ b/engines/titanic/moves/exit_arboretum.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/exit_arboretum.h" + +namespace Titanic { + +CExitArboretum::CExitArboretum() : CMovePlayerTo(), + _fieldC8(0), _fieldCC(0), _fieldD0(1) { +} + +void CExitArboretum::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeNumberLine(_fieldD0, indent); + + CMovePlayerTo::save(file, indent); +} + +void CExitArboretum::load(SimpleFile *file) { + file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + _fieldD0 = file->readNumber(); + + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/exit_arboretum.h b/engines/titanic/moves/exit_arboretum.h new file mode 100644 index 0000000000..f6ebf71515 --- /dev/null +++ b/engines/titanic/moves/exit_arboretum.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EXIT_ARBORETUM_H +#define TITANIC_EXIT_ARBORETUM_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CExitArboretum : public CMovePlayerTo { +protected: + int _fieldC8; + int _fieldCC; + int _fieldD0; +public: + CLASSDEF; + CExitArboretum(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BACKGROUND_H */ diff --git a/engines/titanic/moves/exit_bridge.cpp b/engines/titanic/moves/exit_bridge.cpp new file mode 100644 index 0000000000..b913911341 --- /dev/null +++ b/engines/titanic/moves/exit_bridge.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/exit_bridge.h" + +namespace Titanic { + +CExitBridge::CExitBridge() : CMovePlayerTo() { +} + +void CExitBridge::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + + CMovePlayerTo::save(file, indent); +} + +void CExitBridge::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/exit_bridge.h b/engines/titanic/moves/exit_bridge.h new file mode 100644 index 0000000000..4ab29524db --- /dev/null +++ b/engines/titanic/moves/exit_bridge.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EXIT_BRIDGE_H +#define TITANIC_EXIT_BRIDGE_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CExitBridge : public CMovePlayerTo { +private: + CString _string1; +public: + CLASSDEF; + CExitBridge(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EXIT_BRIDGE_H */ diff --git a/engines/titanic/moves/exit_lift.cpp b/engines/titanic/moves/exit_lift.cpp new file mode 100644 index 0000000000..a264be883d --- /dev/null +++ b/engines/titanic/moves/exit_lift.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/exit_lift.h" + +namespace Titanic { + +void CExitLift::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_value, indent); + CGameObject::save(file, indent); +} + +void CExitLift::load(SimpleFile *file) { + file->readNumber(); + _value = file->readString(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/exit_lift.h b/engines/titanic/moves/exit_lift.h new file mode 100644 index 0000000000..04dabfaf13 --- /dev/null +++ b/engines/titanic/moves/exit_lift.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EXIT_LIFT_H +#define TITANIC_EXIT_LIFT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CExitLift : public CGameObject { +public: + CString _value; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EXIT_LIFT_H */ diff --git a/engines/titanic/moves/exit_pellerator.cpp b/engines/titanic/moves/exit_pellerator.cpp new file mode 100644 index 0000000000..68a2a8da91 --- /dev/null +++ b/engines/titanic/moves/exit_pellerator.cpp @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/exit_pellerator.h" + +namespace Titanic { + +CExitPelleratorStatics *CExitPellerator::_statics; + +void CExitPellerator::init() { + _statics = new CExitPelleratorStatics(); +} + +void CExitPellerator::deinit() { + delete _statics; +} + +void CExitPellerator::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_statics->_v1, indent); + file->writeNumberLine(_statics->_v2, indent); + file->writeNumberLine(_statics->_v3, indent); + + CGameObject::save(file, indent); +} + +void CExitPellerator::load(SimpleFile *file) { + file->readNumber(); + _statics->_v1 = file->readString(); + _statics->_v2 = file->readNumber(); + _statics->_v3 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/exit_pellerator.h b/engines/titanic/moves/exit_pellerator.h new file mode 100644 index 0000000000..280d1e9a6c --- /dev/null +++ b/engines/titanic/moves/exit_pellerator.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EXIT_PELLERATOR_H +#define TITANIC_EXIT_PELLERATOR_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +struct CExitPelleratorStatics { + CString _v1; + int _v2; + int _v3; +}; + +class CExitPellerator : public CGameObject { +private: + static CExitPelleratorStatics *_statics; +public: + CLASSDEF; + static void init(); + static void deinit(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EXIT_PELLERATOR_H */ diff --git a/engines/titanic/moves/exit_state_room.cpp b/engines/titanic/moves/exit_state_room.cpp new file mode 100644 index 0000000000..1c78a69ac2 --- /dev/null +++ b/engines/titanic/moves/exit_state_room.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/exit_state_room.h" + +namespace Titanic { + +CExitStateRoom::CExitStateRoom() : CMovePlayerTo(), _fieldC8(0) { +} + +void CExitStateRoom::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMovePlayerTo::save(file, indent); +} + +void CExitStateRoom::load(SimpleFile *file) { + file->readNumber(); + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/exit_state_room.h b/engines/titanic/moves/exit_state_room.h new file mode 100644 index 0000000000..c0f9737817 --- /dev/null +++ b/engines/titanic/moves/exit_state_room.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EXIT_STATE_ROOM_H +#define TITANIC_EXIT_STATE_ROOM_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CExitStateRoom : public CMovePlayerTo { +protected: + int _fieldC8; +public: + CLASSDEF; + CExitStateRoom(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EXIT_STATE_ROOM_H */ diff --git a/engines/titanic/moves/exit_tiania.cpp b/engines/titanic/moves/exit_tiania.cpp new file mode 100644 index 0000000000..6cb2422b1f --- /dev/null +++ b/engines/titanic/moves/exit_tiania.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/exit_tiania.h" + +namespace Titanic { + +CExitTiania::CExitTiania() : CMovePlayerTo(), _fieldC8(0), + _string1("NULL"), _string2("NULL"), _string3("NULL") { +} + +void CExitTiania::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string3, indent); + + CMovePlayerTo::save(file, indent); +} + +void CExitTiania::load(SimpleFile *file) { + file->readNumber(); + _fieldC8 = file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + _string3 = file->readString(); + + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/exit_tiania.h b/engines/titanic/moves/exit_tiania.h new file mode 100644 index 0000000000..c2b7772ce7 --- /dev/null +++ b/engines/titanic/moves/exit_tiania.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EXIT_TIANIA_H +#define TITANIC_EXIT_TIANIA_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CExitTiania : public CMovePlayerTo { +private: + int _fieldC8; + CString _string1; + CString _string2; + CString _string3; +public: + CLASSDEF; + CExitTiania(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EXIT_TIANIA_H */ diff --git a/engines/titanic/moves/move_player_in_parrot_room.cpp b/engines/titanic/moves/move_player_in_parrot_room.cpp new file mode 100644 index 0000000000..df38c63cd4 --- /dev/null +++ b/engines/titanic/moves/move_player_in_parrot_room.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/move_player_in_parrot_room.h" + +namespace Titanic { + +CMovePlayerInParrotRoom::CMovePlayerInParrotRoom() : CMovePlayerTo() { +} + +void CMovePlayerInParrotRoom::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMovePlayerTo::save(file, indent); +} + +void CMovePlayerInParrotRoom::load(SimpleFile *file) { + file->readNumber(); + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_in_parrot_room.h b/engines/titanic/moves/move_player_in_parrot_room.h new file mode 100644 index 0000000000..de693fe2e2 --- /dev/null +++ b/engines/titanic/moves/move_player_in_parrot_room.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVE_PLAYER_IN_PARROT_ROOM_H +#define TITANIC_MOVE_PLAYER_IN_PARROT_ROOM_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CMovePlayerInParrotRoom : public CMovePlayerTo { +public: + CLASSDEF; + CMovePlayerInParrotRoom(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVE_PLAYER_IN_PARROT_ROOM_H */ diff --git a/engines/titanic/moves/move_player_to.cpp b/engines/titanic/moves/move_player_to.cpp new file mode 100644 index 0000000000..9b6000c4f8 --- /dev/null +++ b/engines/titanic/moves/move_player_to.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +CMovePlayerTo::CMovePlayerTo() : CGameObject() { +} + +void CMovePlayerTo::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_destination, indent); + + CGameObject::save(file, indent); +} + +void CMovePlayerTo::load(SimpleFile *file) { + file->readNumber(); + _destination = file->readString(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_to.h b/engines/titanic/moves/move_player_to.h new file mode 100644 index 0000000000..4bfffcb0b2 --- /dev/null +++ b/engines/titanic/moves/move_player_to.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVE_PLAYER_TO_H +#define TITANIC_MOVE_PLAYER_TO_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CMovePlayerTo : public CGameObject { +protected: + CString _destination; +public: + CLASSDEF; + CMovePlayerTo(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVE_PLAYER_TO_H */ diff --git a/engines/titanic/moves/move_player_to_from.cpp b/engines/titanic/moves/move_player_to_from.cpp new file mode 100644 index 0000000000..1a67dc8505 --- /dev/null +++ b/engines/titanic/moves/move_player_to_from.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/move_player_to_from.h" + +namespace Titanic { + +CMovePlayerToFrom::CMovePlayerToFrom() : CGameObject() { +} + +void CMovePlayerToFrom::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string2, indent); + + CGameObject::save(file, indent); +} + +void CMovePlayerToFrom::load(SimpleFile *file) { + file->readNumber(); + _string2 = file->readString(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_to_from.h b/engines/titanic/moves/move_player_to_from.h new file mode 100644 index 0000000000..c9eefe532f --- /dev/null +++ b/engines/titanic/moves/move_player_to_from.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVE_PLAYER_TO_FROM_H +#define TITANIC_MOVE_PLAYER_TO_FROM_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CMovePlayerToFrom : public CGameObject { +private: + CString _string2; +public: + CLASSDEF; + CMovePlayerToFrom(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVE_PLAYER_TO_FROM_H */ diff --git a/engines/titanic/moves/multi_move.cpp b/engines/titanic/moves/multi_move.cpp new file mode 100644 index 0000000000..fb5570df9b --- /dev/null +++ b/engines/titanic/moves/multi_move.cpp @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/multi_move.h" + +namespace Titanic { + +CMultiMove::CMultiMove() : CMovePlayerTo() { +} + +void CMultiMove::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + file->writeQuotedLine(_string3, indent); + file->writeQuotedLine(_string4, indent); + file->writeQuotedLine(_string5, indent); + + CMovePlayerTo::save(file, indent); +} + +void CMultiMove::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + _string3 = file->readString(); + _string5 = file->readString(); + _string4 = file->readString(); + + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/multi_move.h b/engines/titanic/moves/multi_move.h new file mode 100644 index 0000000000..977afc2a20 --- /dev/null +++ b/engines/titanic/moves/multi_move.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MULTI_MOVE_H +#define TITANIC_MULTI_MOVE_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CMultiMove : public CMovePlayerTo { +private: + CString _string1; + CString _string2; + CString _string3; + CString _string4; + CString _string5; +public: + CLASSDEF; + CMultiMove(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MULTI_MOVE_H */ diff --git a/engines/titanic/moves/pan_from_pel.cpp b/engines/titanic/moves/pan_from_pel.cpp new file mode 100644 index 0000000000..fccc643ec5 --- /dev/null +++ b/engines/titanic/moves/pan_from_pel.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/pan_from_pel.h" + +namespace Titanic { + +CPanFromPel::CPanFromPel() : CMovePlayerTo(), _fieldC8(0) { +} + +void CPanFromPel::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeQuotedLine(_string1, indent); + + CMovePlayerTo::save(file, indent); +} + +void CPanFromPel::load(SimpleFile *file) { + file->readNumber(); + _fieldC8 = file->readNumber(); + _string1 = file->readString(); + + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/pan_from_pel.h b/engines/titanic/moves/pan_from_pel.h new file mode 100644 index 0000000000..c81be9f338 --- /dev/null +++ b/engines/titanic/moves/pan_from_pel.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PAN_FROM_PEL_H +#define TITANIC_PAN_FROM_PEL_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CPanFromPel : public CMovePlayerTo { +protected: + int _fieldC8; + CString _string1; +public: + CLASSDEF; + CPanFromPel(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PAN_FROM_PEL_H */ diff --git a/engines/titanic/moves/restaurant_pan_handler.cpp b/engines/titanic/moves/restaurant_pan_handler.cpp new file mode 100644 index 0000000000..92f55b46cc --- /dev/null +++ b/engines/titanic/moves/restaurant_pan_handler.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/restaurant_pan_handler.h" + +namespace Titanic { + +int CRestaurantPanHandler::_v1; + +void CRestaurantPanHandler::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_string2, indent); + + CMovePlayerTo::save(file, indent); +} + +void CRestaurantPanHandler::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _string1 = file->readString(); + _string2 = file->readString(); + + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/restaurant_pan_handler.h b/engines/titanic/moves/restaurant_pan_handler.h new file mode 100644 index 0000000000..4925aa685b --- /dev/null +++ b/engines/titanic/moves/restaurant_pan_handler.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RESTAURANT_PAN_HANDLER_H +#define TITANIC_RESTAURANT_PAN_HANDLER_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CRestaurantPanHandler : public CMovePlayerTo { +protected: + static int _v1; + + CString _string1; + CString _string2; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RESTAURANT_PAN_HANDLER_H */ diff --git a/engines/titanic/moves/restricted_move.cpp b/engines/titanic/moves/restricted_move.cpp new file mode 100644 index 0000000000..5f18dab8ff --- /dev/null +++ b/engines/titanic/moves/restricted_move.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/restricted_move.h" + +namespace Titanic { + +CRestrictedMove::CRestrictedMove() : CMovePlayerTo(), _fieldC8(0) { +} + +void CRestrictedMove::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldC8, indent); + + CMovePlayerTo::save(file, indent); +} + +void CRestrictedMove::load(SimpleFile *file) { + file->readNumber(); + _fieldC8 = file->readNumber(); + + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/restricted_move.h b/engines/titanic/moves/restricted_move.h new file mode 100644 index 0000000000..bdf093c353 --- /dev/null +++ b/engines/titanic/moves/restricted_move.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RESTRICTED_MOVE_H +#define TITANIC_RESTRICTED_MOVE_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CRestrictedMove : public CMovePlayerTo { +protected: + int _fieldC8; +public: + CLASSDEF; + CRestrictedMove(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RESTRICTED_MOVE_H */ diff --git a/engines/titanic/moves/scraliontis_table.cpp b/engines/titanic/moves/scraliontis_table.cpp new file mode 100644 index 0000000000..77d2f9df60 --- /dev/null +++ b/engines/titanic/moves/scraliontis_table.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/scraliontis_table.h" + +namespace Titanic { + +CScraliontisTable::CScraliontisTable() : CRestaurantPanHandler(), + _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0) { +} + +void CScraliontisTable::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); + + CRestaurantPanHandler::save(file, indent); +} + +void CScraliontisTable::load(SimpleFile *file) { + file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + + CRestaurantPanHandler::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/scraliontis_table.h b/engines/titanic/moves/scraliontis_table.h new file mode 100644 index 0000000000..2ce3745654 --- /dev/null +++ b/engines/titanic/moves/scraliontis_table.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SCRALIONTIS_TABLE_H +#define TITANIC_SCRALIONTIS_TABLE_H + +#include "titanic/moves/restaurant_pan_handler.h" + +namespace Titanic { + +class CScraliontisTable : public CRestaurantPanHandler { +private: + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; +public: + CLASSDEF; + CScraliontisTable(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SCRALIONTIS_TABLE_H */ diff --git a/engines/titanic/moves/trip_down_canal.cpp b/engines/titanic/moves/trip_down_canal.cpp new file mode 100644 index 0000000000..c8051dda03 --- /dev/null +++ b/engines/titanic/moves/trip_down_canal.cpp @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/moves/trip_down_canal.h" + +namespace Titanic { + +CTripDownCanal::CTripDownCanal() : CMovePlayerTo() { +} + +void CTripDownCanal::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMovePlayerTo::save(file, indent); +} + +void CTripDownCanal::load(SimpleFile *file) { + file->readNumber(); + CMovePlayerTo::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/moves/trip_down_canal.h b/engines/titanic/moves/trip_down_canal.h new file mode 100644 index 0000000000..736caf4131 --- /dev/null +++ b/engines/titanic/moves/trip_down_canal.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TRIP_DOWN_CANAL_H +#define TITANIC_TRIP_DOWN_CANAL_H + +#include "titanic/moves/move_player_to.h" + +namespace Titanic { + +class CTripDownCanal : public CMovePlayerTo { +public: + CLASSDEF; + CTripDownCanal(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TRIP_DOWN_CANAL_H */ diff --git a/engines/titanic/npcs/barbot.cpp b/engines/titanic/npcs/barbot.cpp new file mode 100644 index 0000000000..8f1c5e6ab3 --- /dev/null +++ b/engines/titanic/npcs/barbot.cpp @@ -0,0 +1,241 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/barbot.h" + +namespace Titanic { + +int CBarbot::_v0; + +CBarbot::CBarbot() : CTrueTalkNPC() { + _field108 = 0; + _field10C = 0; + _field110 = 0; + _field114 = 0; + _field118 = 0; + _field11C = 0; + _field120 = 0; + _field124 = 0; + _field128 = 0; + _field12C = 0; + _field130 = 0; + _field134 = 0; + _field138 = 0; + _field13C = -1; + _field140 = 30; + _field144 = -1; + _field148 = -1; + _field14C = 0; + _field150 = 0; + _field154 = 0; + _field158 = -1; + _field15C = 0; + _field160 = 0; + _field164 = 558; + _field168 = 585; + _field16C = 659; + _field170 = 692; + _field174 = 802; + _field178 = 816; + _field17C = 1941; + _field180 = 1977; + _field184 = 1901; + _field188 = 1941; + _field18C = 810; + _field190 = 816; + _field194 = 857; + _field198 = 865; + _field19C = 842; + _field1A0 = 857; + _field1A4 = 821; + _field1A8 = 842; + _field1AC = 682; + _field1B0 = 692; + _field1B4 = 1977; + _field1B8 = 2018; + _field1BC = 2140; + _field1C0 = 2170; + _field1C4 = 2101; + _field1C8 = 2139; + _field1CC = 2018; + _field1D0 = 2099; + _field1D4 = 1902; + _field1D8 = 2015; + _field1E0 = 1811; + _field1E4 = 1901; + _field1E8 = 1810; + _field1EC = 1703; + _field1F0 = 1750; + _field1F4 = 1681; + _field1F8 = 1702; + _field1FC = 1642; + + _field200 = 1702; + _field204 = 1571; + _field208 = 1641; + _field20C = 1499; + _field210 = 1570; + _field214 = 1403; + _field218 = 1463; + _field21C = 1464; + _field220 = 1499; + _field224 = 1288; + _field228 = 1295; + _field22C = 1266; + _field230 = 1287; + _field234 = 1245; + _field238 = 1265; + _field23C = 1208; + _field240 = 1244; + _field244 = 1171; + _field248 = 1207; + _field24C = 1120; + _field250 = 1170; + _field254 = 1092; + _field258 = 1120; + _field25C = 1092; + _field260 = 1092; + _field264 = 1044; + _field268 = 1091; + _field26C = 1011; + _field270 = 1043; + _field274 = 1001; + _field278 = 1010; + _field27C = 985; + _field280 = 1001; + _field284 = 927; + _field288 = 984; + _field28C = 912; + _field290 = 926; + _field294 = 898; + _field298 = 906; + _field29C = 802; + _field2A0 = 896; + _field2A4 = 865; + _field2A8 = 896; + _field2AC = 842; + _field2B0 = 865; + _field2B4 = 816; + _field2B8 = 842; + _field2BC = 802; + _field2C0 = 842; + _field2C4 = 740; + _field2C8 = 740; + _field2CC = 740; + _field2D0 = 692; + _field2D4 = 610; + _field2D8 = 558; + _field2E0 = 610; + _field2E4 = 500; + _field2E8 = 558; + _field2EC = 467; + _field2F0 = 500; + _field2F4 = 421; + _field2F8 = 466; + _field2FC = 349; + _field300 = 306; + _field304 = 306; + _field308 = 348; + _field30C = 305; + _field310 = 306; + _field314 = 281; + _field318 = 305; + _field31C = 202; + _field320 = 281; + _field324 = 182; + _field328 = 202; + _field32C = 165; + _field330 = 182; + _field334 = 96; + _field338 = 165; + _field33C = 0; + _field340 = 95; +} + +void CBarbot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_field10C, indent); + file->writeNumberLine(_field110, indent); + file->writeNumberLine(_field114, indent); + file->writeNumberLine(_field118, indent); + file->writeNumberLine(_field11C, indent); + file->writeNumberLine(_field120, indent); + file->writeNumberLine(_field124, indent); + file->writeNumberLine(_field128, indent); + + file->writeNumberLine(_v0, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_field130, indent); + file->writeNumberLine(_field134, indent); + file->writeNumberLine(_field138, indent); + file->writeNumberLine(_field13C, indent); + file->writeNumberLine(_field140, indent); + file->writeNumberLine(_field144, indent); + file->writeNumberLine(_field148, indent); + file->writeNumberLine(_field14C, indent); + file->writeNumberLine(_field150, indent); + file->writeNumberLine(_field154, indent); + file->writeNumberLine(_field158, indent); + file->writeNumberLine(_field15C, indent); + file->writeNumberLine(_field160, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CBarbot::load(SimpleFile *file) { + file->readNumber(); + _field108 = file->readNumber(); + _field10C = file->readNumber(); + _field110 = file->readNumber(); + _field114 = file->readNumber(); + _field118 = file->readNumber(); + _field11C = file->readNumber(); + _field120 = file->readNumber(); + _field124 = file->readNumber(); + _field128 = file->readNumber(); + + _v0 = file->readNumber(); + _field12C = file->readNumber(); + _field130 = file->readNumber(); + _field134 = file->readNumber(); + _field138 = file->readNumber(); + _field13C = file->readNumber(); + _field140 = file->readNumber(); + _field144 = file->readNumber(); + _field148 = file->readNumber(); + _field14C = file->readNumber(); + _field150 = file->readNumber(); + _field154 = file->readNumber(); + _field158 = file->readNumber(); + _field15C = file->readNumber(); + _field160 = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +bool CBarbot::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("TODO: Barbot::CEnterRoomMsg"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/barbot.h b/engines/titanic/npcs/barbot.h new file mode 100644 index 0000000000..7557fdd2c6 --- /dev/null +++ b/engines/titanic/npcs/barbot.h @@ -0,0 +1,194 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BARBOT_H +#define TITANIC_BARBOT_H + +#include "titanic/npcs/true_talk_npc.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CBarbot : public CTrueTalkNPC { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + static int _v0; +private: + int _field108; + int _field10C; + int _field110; + int _field114; + int _field118; + int _field11C; + int _field120; + int _field124; + int _field128; + int _field12C; + int _field130; + int _field134; + int _field138; + int _field13C; + int _field140; + int _field144; + int _field148; + int _field14C; + int _field150; + int _field154; + int _field158; + int _field15C; + int _field160; + int _field164; + int _field168; + int _field16C; + int _field170; + int _field174; + int _field178; + int _field17C; + int _field180; + int _field184; + int _field188; + int _field18C; + int _field190; + int _field194; + int _field198; + int _field19C; + int _field1A0; + int _field1A4; + int _field1A8; + int _field1AC; + int _field1B0; + int _field1B4; + int _field1B8; + int _field1BC; + int _field1C0; + int _field1C4; + int _field1C8; + int _field1CC; + int _field1D0; + int _field1D4; + int _field1D8; + int _field1E0; + int _field1E4; + int _field1E8; + int _field1EC; + int _field1F0; + int _field1F4; + int _field1F8; + int _field1FC; + int _field200; + int _field204; + int _field208; + int _field20C; + int _field210; + int _field214; + int _field218; + int _field21C; + int _field220; + int _field224; + int _field228; + int _field22C; + int _field230; + int _field234; + int _field238; + int _field23C; + int _field240; + int _field244; + int _field248; + int _field24C; + int _field250; + int _field254; + int _field258; + int _field25C; + int _field260; + int _field264; + int _field268; + int _field26C; + int _field270; + int _field274; + int _field278; + int _field27C; + int _field280; + int _field284; + int _field288; + int _field28C; + int _field290; + int _field294; + int _field298; + int _field29C; + int _field2A0; + int _field2A4; + int _field2A8; + int _field2AC; + int _field2B0; + int _field2B4; + int _field2B8; + int _field2BC; + int _field2C0; + int _field2C4; + int _field2C8; + int _field2CC; + int _field2D0; + int _field2D4; + int _field2D8; + int _field2E0; + int _field2E4; + int _field2E8; + int _field2EC; + int _field2F0; + int _field2F4; + int _field2F8; + int _field2FC; + int _field300; + int _field304; + int _field308; + int _field30C; + int _field310; + int _field314; + int _field318; + int _field31C; + int _field320; + int _field324; + int _field328; + int _field32C; + int _field330; + int _field334; + int _field338; + int _field33C; + int _field340; +public: + CLASSDEF; + CBarbot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BARBOT_H */ diff --git a/engines/titanic/npcs/bellbot.cpp b/engines/titanic/npcs/bellbot.cpp new file mode 100644 index 0000000000..7ee0128a1e --- /dev/null +++ b/engines/titanic/npcs/bellbot.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/bellbot.h" + +namespace Titanic { + +CBellBot::CBellBot() : CTrueTalkNPC(), _field108(0) { +} + +void CBellBot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field108, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CBellBot::load(SimpleFile *file) { + file->readNumber(); + _field108 = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/bellbot.h b/engines/titanic/npcs/bellbot.h new file mode 100644 index 0000000000..93c4a2857d --- /dev/null +++ b/engines/titanic/npcs/bellbot.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BELLBOT_H +#define TITANIC_BELLBOT_H + +#include "titanic/npcs/true_talk_npc.h" + +namespace Titanic { + +class CBellBot : public CTrueTalkNPC { +private: + int _field108; +public: + CLASSDEF; + CBellBot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BELLBOT_H */ diff --git a/engines/titanic/npcs/callbot.cpp b/engines/titanic/npcs/callbot.cpp new file mode 100644 index 0000000000..eb0d4b71d5 --- /dev/null +++ b/engines/titanic/npcs/callbot.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/callbot.h" + +namespace Titanic { + +CCallBot::CCallBot() : CGameObject(), _fieldC8(0) { +} + +void CCallBot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_fieldC8, indent); + + CGameObject::save(file, indent); +} + +void CCallBot::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + _fieldC8 = file->readNumber(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/callbot.h b/engines/titanic/npcs/callbot.h new file mode 100644 index 0000000000..9b89d59d3f --- /dev/null +++ b/engines/titanic/npcs/callbot.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CALLBOT_H +#define TITANIC_CALLBOT_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CCallBot : public CGameObject { +protected: + CString _string1; + int _fieldC8; +public: + CLASSDEF; + CCallBot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CALLBOT_H */ diff --git a/engines/titanic/npcs/character.cpp b/engines/titanic/npcs/character.cpp new file mode 100644 index 0000000000..ed36db16d3 --- /dev/null +++ b/engines/titanic/npcs/character.cpp @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/character.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CCharacter, CGameObject) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) +END_MESSAGE_MAP() + +CCharacter::CCharacter() : CGameObject(), _fieldBC(0), _fieldC0(0), _fieldC4(1) { +} + +void CCharacter::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_fieldC0, indent); + file->writeNumberLine(_fieldC4, indent); + file->writeQuotedLine(_charName, indent); + + CGameObject::save(file, indent); +} + +void CCharacter::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _fieldC0 = file->readNumber(); + _fieldC4 = file->readNumber(); + _charName = file->readString(); + + CGameObject::load(file); +} + +bool CCharacter::LeaveViewMsg(CLeaveViewMsg *msg) { + CTurnOff offMsg; + offMsg.execute(this); + + return true; +} + +bool CCharacter::TurnOn(CTurnOn *msg) { + if (!_fieldC4) + _fieldC4 = 1; + + return true; +} + +bool CCharacter::TurnOff(CTurnOff *msg) { + CString charName = getName(); + if (charName == "Deskbot" || charName == "Barbot" || charName == "SuccUBus") { + _fieldC4 = 0; + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/character.h b/engines/titanic/npcs/character.h new file mode 100644 index 0000000000..4912740189 --- /dev/null +++ b/engines/titanic/npcs/character.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CHARACTER_H +#define TITANIC_CHARACTER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CCharacter : public CGameObject { + DECLARE_MESSAGE_MAP; + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); +protected: + int _fieldBC; + int _fieldC0; + int _fieldC4; + CString _charName; +public: + CLASSDEF; + CCharacter(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CHARACTER_H */ diff --git a/engines/titanic/npcs/deskbot.cpp b/engines/titanic/npcs/deskbot.cpp new file mode 100644 index 0000000000..d11b135983 --- /dev/null +++ b/engines/titanic/npcs/deskbot.cpp @@ -0,0 +1,310 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/deskbot.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +static const char *const TALKING_NAMES[] = { + "NeutralTalking", "HandFidget1", "HandFidget2", "LookingAround", + "FriendlyTalking", "MoreRudeness", "HandUp", "TapFingers", + "WaveOn", "WaveArmsAround", "HandsOverEdge" +}; + +static const char *const IDLE_NAMES[] = { + "WaveOn", "HandFidget1", "HandFidget2", "TapFingers", "HandsOverEdge" +}; + +BEGIN_MESSAGE_MAP(CDeskbot, CTrueTalkNPC) + ON_MESSAGE(TurnOn) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(TrueTalkTriggerActionMsg) + ON_MESSAGE(NPCPlayTalkingAnimationMsg) + ON_MESSAGE(NPCPlayIdleAnimationMsg) + ON_MESSAGE(TrueTalkNotifySpeechStartedMsg) + ON_MESSAGE(TrueTalkNotifySpeechEndedMsg) + ON_MESSAGE(TurnOff) +END_MESSAGE_MAP() + +int CDeskbot::_v1; +int CDeskbot::_v2; + +CDeskbot::CDeskbot() : CTrueTalkNPC(), _deskbotActive(false), _classNum(0) { +} + +void CDeskbot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_deskbotActive, indent); + file->writeNumberLine(_classNum, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CDeskbot::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _deskbotActive = file->readNumber(); + _classNum = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +bool CDeskbot::TurnOn(CTurnOn *msg) { + if (!_deskbotActive) { + setVisible(true); + playClip("BellRinging", 4); + playSound("b#69.wav"); + petSetArea(PET_CONVERSATION); + + _npcFlags |= NPCFLAG_20000; + _deskbotActive = true; + } + + return true; +} + +bool CDeskbot::EnterViewMsg(CEnterViewMsg *msg) { + setVisible(false); + _deskbotActive = false; + _fieldC4 = 0; + loadFrame(625); + + return true; +} + +bool CDeskbot::ActMsg(CActMsg *msg) { + if (msg->_action == "2ndClassUpgrade" && getPassengerClass() > 2) { + startTalking(this, 140, findView()); + } + + return true; +} + +bool CDeskbot::MovieEndMsg(CMovieEndMsg *msg) { + bool flag = false; + if (_npcFlags & NPCFLAG_10000) { + if (_classNum) { + petSetArea(PET_ROOMS); + dec54(); + unlockMouse(); + playSound("z#47.wav", 100, 0, 0); + _classNum = false; + } + + _npcFlags &= ~NPCFLAG_10000; + flag = true; + } + + if (_npcFlags & NPCFLAG_40000) { + _deskbotActive = false; + _npcFlags &= ~(NPCFLAG_40000 | NPCFLAG_20000); + + if (_npcFlags & NPCFLAG_80000) { + CTurnOn turnOn; + turnOn.execute("EmbBellbotTrigger"); + unlockMouse(); + changeView("EmbLobby.Node 4.N", ""); + } else if (_npcFlags & NPCFLAG_100000) { + CTurnOn turnOn; + turnOn.execute("EmbDoorBotTrigger"); + unlockMouse(); + changeView("EmbLobby.Node 4.N", ""); + } + + _npcFlags &= ~(NPCFLAG_80000 | NPCFLAG_100000); + flag = true; + } + + if (_npcFlags & NPCFLAG_20000) { + _npcFlags &= ~(NPCFLAG_40000 | NPCFLAG_20000); + endTalking(this, 1, findView()); + + _npcFlags |= NPCFLAG_4; + flag = true; + } + + if (!flag) + CTrueTalkNPC::MovieEndMsg(msg); + + return true; +} + +bool CDeskbot::LeaveViewMsg(CLeaveViewMsg *msg) { + if (_deskbotActive) { + CTurnOff turnOff; + turnOff.execute(this); + } + + return true; +} + +bool CDeskbot::TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg) { + switch (msg->_action) { + case 19: + inc54(); + lockMouse(); + petSetArea(PET_CONVERSATION); + playClip("ReprogramPETInHand", 4); + _npcFlags |= NPCFLAG_10000; + _classNum = msg->_param1; + + switch (_classNum) { + case 1: + petDisplayMessage("You have been upgraded to 1st Class status. Enjoy hugely."); + setPassengerClass(_classNum); + petReassignRoom(_classNum); + break; + case 2: + petDisplayMessage("You have been upgraded to 2nd Class status. Enjoy."); + setPassengerClass(_classNum); + petReassignRoom(_classNum); + break; + case 3: + setPassengerClass(3); + petReassignRoom(_classNum); + break; + default: + break; + } + + case 20: + if (getPassengerClass() == 1) { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->changeLocationClass(4); + } + break; + + case 21: + if (getPassengerClass() == 1) { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->changeLocationClass(3); + } + break; + + case 22: + if (getPassengerClass() == 1) { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->changeLocationClass(2); + } + break; + + case 23: + if (getPassengerClass() == 1) { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->changeLocationClass(1); + } + break; + + case 26: + _npcFlags |= NPCFLAG_80000; + CTurnOff turnOff; + turnOff.execute(this); + lockMouse(); + break; + } + + return true; +} + +bool CDeskbot::NPCPlayTalkingAnimationMsg(CNPCPlayTalkingAnimationMsg *msg) { + if (msg->_value2 != 2) + msg->_names = TALKING_NAMES; + + return true; +} + +bool CDeskbot::NPCPlayIdleAnimationMsg(CNPCPlayIdleAnimationMsg *msg) { + msg->_names = IDLE_NAMES; + return true; +} + +bool CDeskbot::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) { + if (_npcFlags & NPCFLAG_40000) + return true; + + CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(msg); + switch (msg->_dialogueId) { + case 41684: + case 41686: + case 41787: + case 41788: + case 41789: + lockMouse(); + break; + default: + break; + } + + return true; +} + +bool CDeskbot::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) { + if (_npcFlags & NPCFLAG_40000) + return true; + + CTurnOff turnOff; + CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(msg); + + switch (msg->_dialogueId) { + case 41684: + case 41787: + case 41788: + case 41789: + _npcFlags |= NPCFLAG_80000; + turnOff.execute(this); + + case 41686: + _npcFlags |= NPCFLAG_100000; + turnOff.execute(this); + break; + + default: + break; + } + + return true; +} + +bool CDeskbot::TurnOff(CTurnOff *msg) { + if (_deskbotActive) { + stopMovie(); + performAction(1, findView()); + + _npcFlags = (_npcFlags & ~(NPCFLAG_SPEAKING | NPCFLAG_2 | NPCFLAG_4)) | NPCFLAG_40000; + playClip("Closing", 0x14); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/deskbot.h b/engines/titanic/npcs/deskbot.h new file mode 100644 index 0000000000..ab48d63546 --- /dev/null +++ b/engines/titanic/npcs/deskbot.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DESKBOT_H +#define TITANIC_DESKBOT_H + +#include "titanic/npcs/true_talk_npc.h" + +namespace Titanic { + +class CDeskbot : public CTrueTalkNPC { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool ActMsg(CActMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool TrueTalkTriggerActionMsg(CTrueTalkTriggerActionMsg *msg); + bool NPCPlayTalkingAnimationMsg(CNPCPlayTalkingAnimationMsg *msg); + bool NPCPlayIdleAnimationMsg(CNPCPlayIdleAnimationMsg *msg); + bool TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg); + bool TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg); + bool TurnOff(CTurnOff *msg); +private: + static int _v1; + static int _v2; +public: + bool _deskbotActive; + int _classNum; +public: + CLASSDEF; + CDeskbot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DESKBOT_H */ diff --git a/engines/titanic/npcs/doorbot.cpp b/engines/titanic/npcs/doorbot.cpp new file mode 100644 index 0000000000..76db55f92c --- /dev/null +++ b/engines/titanic/npcs/doorbot.cpp @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/doorbot.h" + +namespace Titanic { + +int CDoorbot::_v1; +int CDoorbot::_v2; + +CDoorbot::CDoorbot() : CTrueTalkNPC() { + _field108 = 0; + _field10C = 0; + _field110 = 0; + _field114 = 0; +} + +void CDoorbot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_field10C, indent); + file->writeNumberLine(_field110, indent); + file->writeNumberLine(_field114, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CDoorbot::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + + _field108 = file->readNumber(); + _field10C = file->readNumber(); + _field110 = file->readNumber(); + _field114 = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/doorbot.h b/engines/titanic/npcs/doorbot.h new file mode 100644 index 0000000000..b62026c7d9 --- /dev/null +++ b/engines/titanic/npcs/doorbot.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DOORBOT_H +#define TITANIC_DOORBOT_H + +#include "titanic/npcs/true_talk_npc.h" + +namespace Titanic { + +class CDoorbot : public CTrueTalkNPC { +private: + static int _v1; + static int _v2; +private: + int _field108; + int _field10C; + int _field110; + int _field114; +public: + CLASSDEF; + CDoorbot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DOORBOT_H */ diff --git a/engines/titanic/npcs/liftbot.cpp b/engines/titanic/npcs/liftbot.cpp new file mode 100644 index 0000000000..43daa017c1 --- /dev/null +++ b/engines/titanic/npcs/liftbot.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/liftbot.h" + +namespace Titanic { + +int CLiftBot::_v1; +int CLiftBot::_v2; + +CLiftBot::CLiftBot() : CTrueTalkNPC(), _field108(1) { +} + +void CLiftBot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_v2, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CLiftBot::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + _field108 = file->readNumber(); + _v2 = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +bool CLiftBot::EnterRoomMsg(CEnterRoomMsg *msg) { + warning("CLiftBot::handleEvent"); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/liftbot.h b/engines/titanic/npcs/liftbot.h new file mode 100644 index 0000000000..7550a8a6f0 --- /dev/null +++ b/engines/titanic/npcs/liftbot.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LIFTBOT_H +#define TITANIC_LIFTBOT_H + +#include "titanic/npcs/true_talk_npc.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CLiftBot : public CTrueTalkNPC { + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + static int _v1; + static int _v2; +private: + int _field108; +public: + CLASSDEF; + CLiftBot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIFTBOT_H */ diff --git a/engines/titanic/npcs/maitre_d.cpp b/engines/titanic/npcs/maitre_d.cpp new file mode 100644 index 0000000000..903f3a49c9 --- /dev/null +++ b/engines/titanic/npcs/maitre_d.cpp @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/maitre_d.h" + +namespace Titanic { + +int CMaitreD::_v1; + +CMaitreD::CMaitreD() : CTrueTalkNPC(), + _string2("z#40.wav"), _string3("z#40.wav"), _field108(0), _field118(1), + _field11C(0), _field12C(0), _field130(1), _field134(0), _field138(0) { +} + +void CMaitreD::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_field108, indent); + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_field118, indent); + file->writeNumberLine(_field11C, indent); + file->writeQuotedLine(_string3, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_field130, indent); + + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_field134, indent); + file->writeNumberLine(_field138, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CMaitreD::load(SimpleFile *file) { + file->readNumber(); + _field108 = file->readNumber(); + _string2 = file->readString(); + _field118 = file->readNumber(); + _field11C = file->readNumber(); + _string3 = file->readString(); + _field12C = file->readNumber(); + _field130 = file->readNumber(); + + _v1 = file->readNumber(); + _field134 = file->readNumber(); + _field138 = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/maitre_d.h b/engines/titanic/npcs/maitre_d.h new file mode 100644 index 0000000000..af73f02a9a --- /dev/null +++ b/engines/titanic/npcs/maitre_d.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAITRED_H +#define TITANIC_MAITRED_H + +#include "titanic/npcs/true_talk_npc.h" + +namespace Titanic { + +class CMaitreD : public CTrueTalkNPC { +private: + static int _v1; +private: + int _field108; + CString _string2; + int _field118; + int _field11C; + CString _string3; + int _field12C; + int _field130; + int _field134; + int _field138; +public: + CLASSDEF; + CMaitreD(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAITRED_H */ diff --git a/engines/titanic/npcs/mobile.cpp b/engines/titanic/npcs/mobile.cpp new file mode 100644 index 0000000000..8a45f9e3cf --- /dev/null +++ b/engines/titanic/npcs/mobile.cpp @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/mobile.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CMobile, CCharacter); + +CMobile::CMobile() : CCharacter(), _fieldDC(0) { +} + +void CMobile::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writePoint(_pos1, indent); + file->writeNumberLine(_fieldDC, indent); + + CCharacter::save(file, indent); +} + +void CMobile::load(SimpleFile *file) { + file->readNumber(); + _pos1 = file->readPoint(); + _fieldDC = file->readNumber(); + + CCharacter::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/mobile.h b/engines/titanic/npcs/mobile.h new file mode 100644 index 0000000000..68e74a5afe --- /dev/null +++ b/engines/titanic/npcs/mobile.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOBILE_H +#define TITANIC_MOBILE_H + +#include "titanic/npcs/character.h" + +namespace Titanic { + +class CMobile : public CCharacter { + DECLARE_MESSAGE_MAP; +private: + Point _pos1; + int _fieldDC; +public: + CLASSDEF; + CMobile(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOBILE_H */ diff --git a/engines/titanic/npcs/parrot.cpp b/engines/titanic/npcs/parrot.cpp new file mode 100644 index 0000000000..49e4f4066e --- /dev/null +++ b/engines/titanic/npcs/parrot.cpp @@ -0,0 +1,143 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/parrot.h" + +namespace Titanic { + +int CParrot::_v1; +int CParrot::_v2; +int CParrot::_v3; +int CParrot::_v4; +int CParrot::_v5; + +CParrot::CParrot() : CTrueTalkNPC() { + _field108 = 0; + _string2 = "CarryParrot"; + _field118 = 1; + _field11C = 25; + _field120 = 0; + _field124 = 73; + _field128 = 58; + _field12C = 0; + _field130 = 0; + _field134 = 0; + _field138 = 851; + _field13C = 851; + _field140 = 265; + _field144 = 274; + _field148 = 726; + _field14C = 730; + _field150 = 510; + _field154 = 570; + _field158 = 569; + _field15C = 689; + _field160 = 690; + _field164 = 725; + _field168 = 375; + _field16C = 508; + _field170 = 363; + _field174 = 375; + _field178 = 303; + _field17C = 313; + _field180 = 279; + _field184 = 302; + _field188 = 260; + _field18C = 264; + _field190 = 315; + _field194 = 327; + _field198 = 330; + _field19C = 360; + _field1A0 = 175; + _field1A4 = 259; + _field1A8 = 175; + _field1AC = 175; + _field1B0 = 162; + _field1B4 = 175; + _field1B8 = 150; + _field1BC = 162; + _field1C0 = 135; + _field1C4 = 150; + _field1C8 = 95; + _field1CC = 135; + _field1D0 = 76; + _field1D4 = 95; + _field1D8 = 55; + _field1DC = 76; + _field1E0 = 30; + _field1E4 = 55; + _field1E8 = 0; + _field1EC = 30; + + _assetName = "z454.dlg"; + _assetNumber = 0x13880; +} + +void CParrot::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_assetNumber, indent); + + file->writeQuotedLine(_assetName, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_v1, indent); + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_v3, indent); + + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_field118, indent); + file->writeNumberLine(_field11C, indent); + file->writeNumberLine(_field120, indent); + file->writeNumberLine(_field124, indent); + file->writeNumberLine(_field128, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_field130, indent); + file->writeNumberLine(_v4, indent); + file->writeNumberLine(_v5, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CParrot::load(SimpleFile *file) { + file->readNumber(); + _assetNumber = file->readNumber(); + + _assetName = file->readString(); + _field108 = file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _v3 = file->readNumber(); + + _string2 = file->readString(); + _field118 = file->readNumber(); + _field11C = file->readNumber(); + _field120 = file->readNumber(); + _field124 = file->readNumber(); + _field128 = file->readNumber(); + _field12C = file->readNumber(); + _field130 = file->readNumber(); + _v4 = file->readNumber(); + _v5 = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/parrot.h b/engines/titanic/npcs/parrot.h new file mode 100644 index 0000000000..a3c8540f0e --- /dev/null +++ b/engines/titanic/npcs/parrot.h @@ -0,0 +1,111 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_H +#define TITANIC_PARROT_H + +#include "titanic/npcs/true_talk_npc.h" + +namespace Titanic { + +class CParrot : public CTrueTalkNPC { +public: + static int _v1; + static int _v2; + static int _v3; + static int _v4; + static int _v5; +private: + int _field108; + CString _string2; + int _field118; + int _field11C; + int _field120; + int _field124; + int _field128; + int _field12C; + int _field130; + int _field134; + int _field138; + int _field13C; + int _field140; + int _field144; + int _field148; + int _field14C; + int _field150; + int _field154; + int _field158; + int _field15C; + int _field160; + int _field164; + int _field168; + int _field16C; + int _field170; + int _field174; + int _field178; + int _field17C; + int _field180; + int _field184; + int _field188; + int _field18C; + int _field190; + int _field194; + int _field198; + int _field19C; + int _field1A0; + int _field1A4; + int _field1A8; + int _field1AC; + int _field1B0; + int _field1B4; + int _field1B8; + int _field1BC; + int _field1C0; + int _field1C4; + int _field1C8; + int _field1CC; + int _field1D0; + int _field1D4; + int _field1D8; + int _field1DC; + int _field1E0; + int _field1E4; + int _field1E8; + int _field1EC; +public: + CLASSDEF; + CParrot(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_H */ diff --git a/engines/titanic/npcs/robot_controller.cpp b/engines/titanic/npcs/robot_controller.cpp new file mode 100644 index 0000000000..98866e4505 --- /dev/null +++ b/engines/titanic/npcs/robot_controller.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/robot_controller.h" + +namespace Titanic { + +CRobotController::CRobotController() : CGameObject(), _string1("BellBot") { +} + +void CRobotController::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_string1, indent); + + CGameObject::save(file, indent); +} + +void CRobotController::load(SimpleFile *file) { + file->readNumber(); + _string1 = file->readString(); + + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/robot_controller.h b/engines/titanic/npcs/robot_controller.h new file mode 100644 index 0000000000..6cbf57aef2 --- /dev/null +++ b/engines/titanic/npcs/robot_controller.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ROBOT_CONTROLLER_H +#define TITANIC_ROBOT_CONTROLLER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CRobotController : public CGameObject { +protected: + CString _string1; +public: + CLASSDEF; + CRobotController(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ROBOT_CONTROLLER_H */ diff --git a/engines/titanic/npcs/starlings.cpp b/engines/titanic/npcs/starlings.cpp new file mode 100644 index 0000000000..333f4c4b7a --- /dev/null +++ b/engines/titanic/npcs/starlings.cpp @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/starlings.h" + +namespace Titanic { + +int CStarlings::_v1; + +CStarlings::CStarlings() : CCharacter() { +} + +void CStarlings::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_v1, indent); + + CCharacter::save(file, indent); +} + +void CStarlings::load(SimpleFile *file) { + file->readNumber(); + _v1 = file->readNumber(); + + CCharacter::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/starlings.h b/engines/titanic/npcs/starlings.h new file mode 100644 index 0000000000..4d96e5c77f --- /dev/null +++ b/engines/titanic/npcs/starlings.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STARLINGS_H +#define TITANIC_STARLINGS_H + +#include "titanic/npcs/character.h" + +namespace Titanic { + +class CStarlings : public CCharacter { +private: + static int _v1; +public: + CLASSDEF; + CStarlings(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STARLING_H */ diff --git a/engines/titanic/npcs/succubus.cpp b/engines/titanic/npcs/succubus.cpp new file mode 100644 index 0000000000..f66a59cb84 --- /dev/null +++ b/engines/titanic/npcs/succubus.cpp @@ -0,0 +1,215 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/succubus.h" + +namespace Titanic { + +int CSuccUBus::_v0; +int CSuccUBus::_v1; +int CSuccUBus::_v2; +int CSuccUBus::_v3; +int CSuccUBus::_v4; + +CSuccUBus::CSuccUBus() : CTrueTalkNPC() { + _field108 = -1; + _field10C = -1; + _field110 = -1; + _field114 = -1; + _field118 = 0x44; + _field11C = 0xA8; + _field120 = 0xA8; + _field124 = 0xF8; + _field128 = 0; + _field12C = 0x0E; + _field130 = 0x0E; + _field134 = 27; + _field138 = 40; + _field13C = 0x44; + _field140 = 1; + _field144 = 0; + _field148 = 0; + _field14C = 0; + _field150 = 0xE0; + _field154 = 0; + _field158 = 0; + _field15C = 0; + _string2 = "NULL"; + _field16C = 28; + _field170 = 40; + _field174 = 82; + _field178 = 284; + _field17C = 148; + _field180 = 339; + _field184 = 15; + _field188 = 0; + _field18C = 0; + _field190 = 0; + _field194 = 240; + _field198 = 340; + _field19C = 0; + _field1A0 = -1; + _field1A4 = 0; + _field1A8 = 0; + _field1AC = 0; + _field1B0 = 0; + _field1B4 = 303; + _field1B8 = 312; + _field1BC = 313; + _field1C0 = 325; + _field1C4 = 326; + _field1C8 = 347; + _field1CC = 348; + _field1D0 = 375; + _field1D4 = 1; + _field1D8 = 0; +} + +void CSuccUBus::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + + file->writeNumberLine(_v0, indent); + file->writeNumberLine(_field108, indent); + file->writeNumberLine(_field10C, indent); + file->writeNumberLine(_field110, indent); + file->writeNumberLine(_field114, indent); + file->writeNumberLine(_field118, indent); + file->writeNumberLine(_field11C, indent); + file->writeNumberLine(_field120, indent); + file->writeNumberLine(_field124, indent); + file->writeNumberLine(_field128, indent); + file->writeNumberLine(_field12C, indent); + file->writeNumberLine(_field130, indent); + file->writeNumberLine(_field134, indent); + file->writeNumberLine(_field138, indent); + file->writeNumberLine(_field13C, indent); + file->writeNumberLine(_field140, indent); + + file->writeNumberLine(_v2, indent); + file->writeNumberLine(_field148, indent); + file->writeNumberLine(_field14C, indent); + file->writeNumberLine(_field150, indent); + file->writeNumberLine(_field154, indent); + file->writeNumberLine(_field158, indent); + file->writeNumberLine(_field15C, indent); + + file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_field16C, indent); + file->writeNumberLine(_field170, indent); + file->writeNumberLine(_field174, indent); + file->writeNumberLine(_field178, indent); + file->writeNumberLine(_field17C, indent); + file->writeNumberLine(_field180, indent); + file->writeNumberLine(_field184, indent); + file->writeNumberLine(_field188, indent); + file->writeNumberLine(_field18C, indent); + file->writeNumberLine(_field190, indent); + file->writeNumberLine(_field194, indent); + file->writeNumberLine(_field198, indent); + file->writeNumberLine(_field19C, indent); + file->writeNumberLine(_field1A0, indent); + file->writeNumberLine(_field1A4, indent); + file->writeNumberLine(_field1A8, indent); + file->writeNumberLine(_field1AC, indent); + file->writeNumberLine(_field1B0, indent); + file->writeNumberLine(_field1B4, indent); + file->writeNumberLine(_field1B8, indent); + file->writeNumberLine(_field1BC, indent); + file->writeNumberLine(_field1C0, indent); + file->writeNumberLine(_field1C4, indent); + file->writeNumberLine(_field1C8, indent); + file->writeNumberLine(_field1CC, indent); + file->writeNumberLine(_field1D0, indent); + file->writeNumberLine(_field1D4, indent); + + file->writeNumberLine(_v3, indent); + file->writeNumberLine(_field1D8, indent); + file->writeNumberLine(_field104, indent); + + CTrueTalkNPC::save(file, indent); +} + +void CSuccUBus::load(SimpleFile *file) { + file->readNumber(); + + _v0 = file->readNumber(); + _field108 = file->readNumber(); + _field10C = file->readNumber(); + _field110 = file->readNumber(); + _field114 = file->readNumber(); + _field118 = file->readNumber(); + _field11C = file->readNumber(); + _field120 = file->readNumber(); + _field124 = file->readNumber(); + _field128 = file->readNumber(); + _field12C = file->readNumber(); + _field130 = file->readNumber(); + _field134 = file->readNumber(); + _field138 = file->readNumber(); + _field13C = file->readNumber(); + _field140 = file->readNumber(); + + _v2 = file->readNumber(); + _field148 = file->readNumber(); + _field14C = file->readNumber(); + _field150 = file->readNumber(); + _field154 = file->readNumber(); + _field158 = file->readNumber(); + _field15C = file->readNumber(); + + _string2 = file->readString(); + _field16C = file->readNumber(); + _field170 = file->readNumber(); + _field174 = file->readNumber(); + _field178 = file->readNumber(); + _field17C = file->readNumber(); + _field180 = file->readNumber(); + _field184 = file->readNumber(); + _field188 = file->readNumber(); + _field18C = file->readNumber(); + _field190 = file->readNumber(); + _field194 = file->readNumber(); + _field198 = file->readNumber(); + _field19C = file->readNumber(); + _field1A0 = file->readNumber(); + _field1A4 = file->readNumber(); + _field1A8 = file->readNumber(); + _field1AC = file->readNumber(); + _field1B0 = file->readNumber(); + _field1B4 = file->readNumber(); + _field1B8 = file->readNumber(); + _field1BC = file->readNumber(); + _field1C0 = file->readNumber(); + _field1C4 = file->readNumber(); + _field1C8 = file->readNumber(); + _field1CC = file->readNumber(); + _field1D0 = file->readNumber(); + _field1D4 = file->readNumber(); + + _v3 = file->readNumber(); + _field1D8 = file->readNumber(); + _field104 = file->readNumber(); + + CTrueTalkNPC::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/succubus.h b/engines/titanic/npcs/succubus.h new file mode 100644 index 0000000000..f6f5a6b9e9 --- /dev/null +++ b/engines/titanic/npcs/succubus.h @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SUCCUBUS_H +#define TITANIC_SUCCUBUS_H + +#include "titanic/npcs/true_talk_npc.h" + +namespace Titanic { + +class CSuccUBus : public CTrueTalkNPC { +private: + static int _v0; + static int _v1; + static int _v2; + static int _v3; + static int _v4; +private: + int _field108; + int _field10C; + int _field110; + int _field114; + int _field118; + int _field11C; + int _field120; + int _field124; + int _field128; + int _field12C; + int _field130; + int _field134; + int _field138; + int _field13C; + int _field140; + int _field144; + int _field148; + int _field14C; + int _field150; + int _field154; + int _field158; + int _field15C; + CString _string2; + int _field16C; + int _field170; + int _field174; + int _field178; + int _field17C; + int _field180; + int _field184; + int _field188; + int _field18C; + int _field190; + int _field194; + int _field198; + int _field19C; + int _field1A0; + int _field1A4; + int _field1A8; + int _field1AC; + int _field1B0; + int _field1B4; + int _field1B8; + int _field1BC; + int _field1C0; + int _field1C4; + int _field1C8; + int _field1CC; + int _field1D0; + int _field1D4; + int _field1D8; +public: + CLASSDEF; + CSuccUBus(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SUCCUBUS_H */ diff --git a/engines/titanic/npcs/summon_bots.cpp b/engines/titanic/npcs/summon_bots.cpp new file mode 100644 index 0000000000..8796e5ffda --- /dev/null +++ b/engines/titanic/npcs/summon_bots.cpp @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/summon_bots.h" + +namespace Titanic { + +CSummonBots::CSummonBots() : CRobotController(), _string2("NULL"), + _fieldC8(0), _fieldCC(0) { +} + +void CSummonBots::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldC8, indent); + file->writeNumberLine(_fieldCC, indent); + file->writeQuotedLine(_string2, indent); + + CRobotController::save(file, indent); +} + +void CSummonBots::load(SimpleFile *file) { + file->readNumber(); + _fieldC8 = file->readNumber(); + _fieldCC = file->readNumber(); + _string2 = file->readString(); + + CRobotController::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/summon_bots.h b/engines/titanic/npcs/summon_bots.h new file mode 100644 index 0000000000..ee537fee76 --- /dev/null +++ b/engines/titanic/npcs/summon_bots.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SUMMON_BOTS_H +#define TITANIC_SUMMON_BOTS_H + +#include "titanic/npcs/robot_controller.h" + +namespace Titanic { + +class CSummonBots : public CRobotController { +protected: + CString _string2; + int _fieldC8; + int _fieldCC; +public: + CLASSDEF; + CSummonBots(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SUMMON_BOTS_H */ diff --git a/engines/titanic/npcs/titania.cpp b/engines/titanic/npcs/titania.cpp new file mode 100644 index 0000000000..34c21d0efe --- /dev/null +++ b/engines/titanic/npcs/titania.cpp @@ -0,0 +1,77 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/titania.h" + +namespace Titanic { + +CTitania::CTitania() : CCharacter() { + _fieldD4 = 0; + _fieldD8 = 0; + _fieldE0 = 0; + _fieldE4 = 0; + _fieldE8 = 0; + _fieldEC = 0; + _fieldF0 = 0; + _fieldF4 = 0; + _fieldF8 = 0; + _fieldFC = 0; + _field100 = 1; +} + +void CTitania::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldD4, indent); + file->writeNumberLine(_fieldD8, indent); + file->writeNumberLine(_fieldDC, indent); + file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_field100, indent); + + CCharacter::save(file, indent); +} + +void CTitania::load(SimpleFile *file) { + file->readNumber(); + _fieldD4 = file->readNumber(); + _fieldD8 = file->readNumber(); + _fieldDC = file->readNumber(); + _fieldE0 = file->readNumber(); + _fieldE4 = file->readNumber(); + _fieldE8 = file->readNumber(); + _fieldEC = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + _fieldF8 = file->readNumber(); + _fieldFC = file->readNumber(); + _field100 = file->readNumber(); + + CCharacter::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/titania.h b/engines/titanic/npcs/titania.h new file mode 100644 index 0000000000..4edd626ab6 --- /dev/null +++ b/engines/titanic/npcs/titania.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TITANIA_H +#define TITANIC_TITANIA_H + +#include "titanic/npcs/character.h" + +namespace Titanic { + +class CTitania : public CCharacter { +private: + int _fieldD4; + int _fieldD8; + int _fieldDC; + int _fieldE0; + int _fieldE4; + int _fieldE8; + int _fieldEC; + int _fieldF0; + int _fieldF4; + int _fieldF8; + int _fieldFC; + int _field100; +public: + CLASSDEF; + CTitania(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TITANIA_H */ diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp new file mode 100644 index 0000000000..9310f285e5 --- /dev/null +++ b/engines/titanic/npcs/true_talk_npc.cpp @@ -0,0 +1,229 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/npcs/true_talk_npc.h" +#include "titanic/core/view_item.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/titanic.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CTrueTalkNPC, CCharacter) + ON_MESSAGE(TextInputMsg) + ON_MESSAGE(TrueTalkGetAssetDetailsMsg) + ON_MESSAGE(DismissBotMsg) + ON_MESSAGE(TrueTalkNotifySpeechStartedMsg) + ON_MESSAGE(TrueTalkNotifySpeechEndedMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(NPCQueueIdleAnimMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(NPCPlayAnimationMsg) +END_MESSAGE_MAP() + +CTrueTalkNPC::CTrueTalkNPC() : _assetName("z451.dlg"), + _assetNumber(0x11170), _fieldE4(0), _npcFlags(0), _soundId(0), _fieldF0(0), + _fieldF4(0), _fieldF8(0), _speechTimerId(0), _field100(0), _field104(0) { +} + +void CTrueTalkNPC::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_assetNumber, indent); + file->writeQuotedLine(_assetName, indent); + file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_npcFlags, indent); + file->writeNumberLine(_soundId, indent); + file->writeNumberLine(_fieldF0, indent); + file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_fieldF8, indent); + file->writeNumberLine(_speechTimerId, indent); + file->writeNumberLine(_field100, indent); + file->writeNumberLine(_field104, indent); + + CCharacter::save(file, indent); +} + +void CTrueTalkNPC::load(SimpleFile *file) { + file->readNumber(); + _assetNumber = file->readNumber(); + _assetName = file->readString(); + _fieldE4 = file->readNumber(); + _npcFlags = file->readNumber(); + _soundId = file->readNumber(); + _fieldF0 = file->readNumber(); + _fieldF4 = file->readNumber(); + _fieldF8 = file->readNumber(); + _speechTimerId = file->readNumber(); + _field100 = file->readNumber(); + _field104 = file->readNumber(); + + CCharacter::load(file); +} + +bool CTrueTalkNPC::TextInputMsg(CTextInputMsg *msg) { + processInput(msg, _field104 ? findView() : nullptr); + return true; +} + +bool CTrueTalkNPC::TrueTalkGetAssetDetailsMsg(CTrueTalkGetAssetDetailsMsg *msg) { + msg->_filename = _assetName; + msg->_numValue = _assetNumber; + return true; +} + +bool CTrueTalkNPC::DismissBotMsg(CDismissBotMsg *msg) { + performAction(1, 0); + return true; +} + +bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) { + _npcFlags |= NPCFLAG_SPEAKING; + ++_field100; + + if (!(_npcFlags & NPCFLAG_8)) { + if (_speechTimerId) + stopTimer(_speechTimerId); + + _soundId = msg->_soundId; + _fieldF0 = g_vm->_events->getTicksCount(); + + if (hasActiveMovie() || (_npcFlags & NPCFLAG_2)) { + _npcFlags &= ~NPCFLAG_2; + stopMovie(); + + CNPCPlayTalkingAnimationMsg msg1(_soundId, 0, 0); + msg1.execute(this); + + if (msg1._names) { + CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1); + msg2.execute(this); + } + } + } + + return true; +} + +bool CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) { + _npcFlags &= ~NPCFLAG_SPEAKING; + --_field100; + _soundId = 0; + + if (!(_npcFlags & NPCFLAG_8)) { + CNPCPlayTalkingAnimationMsg msg1(0, 2, 0); + msg1.execute(this); + CNPCQueueIdleAnimMsg msg2; + msg2.execute(this); + } + + return true; +} + +bool CTrueTalkNPC::MovieEndMsg(CMovieEndMsg *msg) { + if (_npcFlags & NPCFLAG_2) { + _npcFlags &= ~NPCFLAG_2; + CNPCQueueIdleAnimMsg idleMsg; + idleMsg.execute(this); + return true; + } else if (!(_npcFlags & NPCFLAG_SPEAKING)) { + return false; + } + + int diff = g_vm->_events->getTicksCount() - _fieldF0; + int ticks = MAX((int)_soundId - diff, 0); + CNPCPlayTalkingAnimationMsg msg1(ticks, ticks > 1000 ? 2 : 1, 0); + msg1.execute(this); + + if (msg1._names) { + CNPCPlayAnimationMsg msg2(msg1._names, msg1._value1); + msg2.execute(this); + } + + return true; +} + +bool CTrueTalkNPC::NPCQueueIdleAnimMsg(CNPCQueueIdleAnimMsg *msg) { + int rndVal = g_vm->getRandomNumber(_fieldF8 - 1) - (_fieldF8 / 2); + _speechTimerId = startAnimTimer("NPCIdleAnim", _fieldF4 + rndVal, 0); + + return true; +} + +bool CTrueTalkNPC::TimerMsg(CTimerMsg *msg) { + if (_npcFlags & NPCFLAG_4) { + if (_field100 > 0) + return false; + + CNPCPlayIdleAnimationMsg idleMsg; + if (idleMsg.execute(this)) { + if (idleMsg._names) { + CNPCPlayAnimationMsg animMsg(idleMsg._names, 0); + animMsg.execute(this); + } + + _npcFlags &= ~NPCFLAG_2; + } + } + + _speechTimerId = 0; + return true; +} + +bool CTrueTalkNPC::NPCPlayAnimationMsg(CNPCPlayAnimationMsg *msg) { + warning("CTrueTalkNPC::NPCPlayAnimationMsg"); + return true; +} + +void CTrueTalkNPC::processInput(CTextInputMsg *msg, CViewItem *view) { + CTrueTalkManager *talkManager = getGameManager()->getTalkManager(); + if (talkManager) + talkManager->processInput(this, msg, view); +} + +void CTrueTalkNPC::stopAnimTimer(int id) { + getGameManager()->stopTimer(id); +} + +void CTrueTalkNPC::setView(CViewItem *view) { + CTrueTalkManager *talkManager = getGameManager()->getTalkManager(); + if (talkManager) + talkManager->start3(this, view); +} + +void CTrueTalkNPC::startTalker(CViewItem *view) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + gameManager->getTalkManager()->start4(this, view); +} + +void CTrueTalkNPC::performAction(bool startTalkingFlag, CViewItem *destView) { + CPetControl *pet = getPetControl(); + if (pet) + pet->resetActiveNPC(); + + if (startTalkingFlag) + startTalker(destView); + + if (pet) + pet->convResetNPC(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h new file mode 100644 index 0000000000..0319f7e059 --- /dev/null +++ b/engines/titanic/npcs/true_talk_npc.h @@ -0,0 +1,102 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TRUE_TALK_NPC_H +#define TITANIC_TRUE_TALK_NPC_H + +#include "titanic/npcs/character.h" +#include "titanic/messages/messages.h" +#include "titanic/true_talk/tt_talker.h" + +namespace Titanic { + +enum NpcFlag { + NPCFLAG_SPEAKING = 1, NPCFLAG_2 = 2, NPCFLAG_4 = 4, NPCFLAG_8 = 8, + NPCFLAG_10000 = 0x10000, NPCFLAG_20000 = 0x20000, NPCFLAG_40000 = 0x40000, + NPCFLAG_80000 = 0x80000, NPCFLAG_100000 = 0x100000 +}; + +class CViewItem; + +class CTrueTalkNPC : public CCharacter { + DECLARE_MESSAGE_MAP; + bool TextInputMsg(CTextInputMsg *msg); + bool TrueTalkGetAssetDetailsMsg(CTrueTalkGetAssetDetailsMsg *msg); + bool DismissBotMsg(CDismissBotMsg *msg); + bool TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg); + bool TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool NPCQueueIdleAnimMsg(CNPCQueueIdleAnimMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool NPCPlayAnimationMsg(CNPCPlayAnimationMsg *msg); +protected: + int _assetNumber; + CString _assetName; + int _fieldE4; + uint _npcFlags; + uint _soundId; + int _fieldF0; + int _fieldF4; + int _fieldF8; + int _speechTimerId; + int _field100; + int _field104; +protected: + void processInput(CTextInputMsg *msg, CViewItem *view); + + /** + * Stop an animation timer + */ + void stopAnimTimer(int id); + + /** + * Perform an action + */ + void performAction(bool startTalking, CViewItem *view); +public: + CLASSDEF; + CTrueTalkNPC(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Set the view for the NPC + */ + void setView(CViewItem *view); + + /** + * Start the talker in the given view + */ + void startTalker(CViewItem *view); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TRUE_TALK_NPC_H */ diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp new file mode 100644 index 0000000000..b32a7907a4 --- /dev/null +++ b/engines/titanic/pet_control/pet_control.cpp @@ -0,0 +1,680 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_control.h" +#include "titanic/carry/carry.h" +#include "titanic/core/project_item.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/pet_messages.h" +#include "titanic/game_manager.h" +#include "titanic/game_state.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPetControl, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(MouseDragMoveMsg) + ON_MESSAGE(MouseDragEndMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MouseDoubleClickMsg) + ON_MESSAGE(KeyCharMsg) + ON_MESSAGE(VirtualKeyCharMsg) + ON_MESSAGE(TimerMsg) +END_MESSAGE_MAP() + +CPetControl::CPetControl() : CGameObject(), + _currentArea(PET_CONVERSATION), _inputLockCount(0), _areaLockCount(0), + _areaChangeType(-1), _activeNPC(nullptr), _remoteTarget(nullptr), + _hiddenRoom(nullptr), _drawBounds(20, 350, 620, 480) { + _sections[PET_INVENTORY] = &_inventory; + _sections[PET_CONVERSATION] = &_conversations; + _sections[PET_REMOTE] = &_remote; + _sections[PET_ROOMS] = &_rooms; + _sections[PET_REAL_LIFE] = &_realLife; + _sections[PET_STARFIELD] = &_starfield; + _sections[PET_MESSAGE] = &_message; +} + +void CPetControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + file->writeNumberLine(_currentArea, indent); + file->writeQuotedLine(_activeNPCName, indent); + file->writeQuotedLine(_remoteTargetName, indent); + + saveAreas(file, indent); + CGameObject::save(file, indent); +} + +void CPetControl::load(SimpleFile *file) { + int val = file->readNumber(); + isValid(); + + if (!val) { + _currentArea = (PetArea)file->readNumber(); + _activeNPCName = file->readString(); + _remoteTargetName = file->readString(); + + loadAreas(file, 0); + } + + CGameObject::load(file); +} + +void CPetControl::setup() { + _conversations.setup(this); + _rooms.setup(this); + _remote.setup(this); + _inventory.setup(this); + _starfield.setup(this); + _realLife.setup(this); + _message.setup(this); + _frame.setup(this); +} + +bool CPetControl::isValid() { + return _conversations.isValid(this) && + _rooms.isValid(this) && + _remote.isValid(this) && + _inventory.isValid(this) && + _starfield.isValid(this) && + _realLife.isValid(this) && + _message.isValid(this) && + _frame.isValid(this); +} + +void CPetControl::loadAreas(SimpleFile *file, int param) { + _conversations.load(file, param); + _rooms.load(file, param); + _remote.load(file, param); + _inventory.load(file, param); + _starfield.load(file, param); + _realLife.load(file, param); + _message.load(file, param); + _frame.load(file, param); +} + +void CPetControl::saveAreas(SimpleFile *file, int indent) { + _conversations.save(file, indent); + _rooms.save(file, indent); + _remote.save(file, indent); + _inventory.save(file, indent); + _starfield.save(file, indent); + _realLife.save(file, indent); + _message.save(file, indent); + _frame.save(file, indent); +} + +void CPetControl::draw(CScreenManager *screenManager) { + CGameManager *gameManager = getGameManager(); + Rect bounds = _drawBounds; + bounds.constrain(gameManager->_bounds); + + if (!bounds.isEmpty()) { + if (_areaChangeType >= 0) { + _inventory.changed(_areaChangeType); + _areaChangeType = -1; + } + + _frame.drawFrame(screenManager); + + // Draw the specific area that's currently active + _sections[_currentArea]->draw(screenManager); + } +} + +Rect CPetControl::getBounds() const { + return _sections[_currentArea]->getBounds(); +} + +void CPetControl::postLoad() { + CProjectItem *root = getRoot(); + + if (!_activeNPCName.empty() && root) + _activeNPC = root->findByName(_activeNPCName); + if (!_remoteTargetName.empty() && root) + _remoteTarget = static_cast<CGameObject *>(root->findByName(_remoteTargetName)); + + setArea(_currentArea); + loaded(); +} + +void CPetControl::loaded() { + _conversations.postLoad(); + _rooms.postLoad(); + _remote.postLoad(); + _inventory.postLoad(); + _starfield.postLoad(); + _realLife.postLoad(); + _message.postLoad(); + _frame.postLoad(); +} + +void CPetControl::enterNode(CNodeItem *node) { + getGameManager()->_gameState.enterNode(); +} + +void CPetControl::enterRoom(CRoomItem *room) { + _rooms.enterRoom(room); + _remote.enterRoom(room); +} + +void CPetControl::resetRemoteTarget() { + _remoteTarget = nullptr; + _remoteTargetName.clear(); +} + +void CPetControl::setActiveNPC(CTrueTalkNPC *npc) { + if (_activeNPC == npc) { + if (_activeNPC) { + _activeNPCName = npc->getName(); + _conversations.displayNPCName(npc); + } else { + _activeNPCName = ""; + } + } +} + +void CPetControl::refreshNPC() { + _conversations.setNPC(_activeNPCName); +} + +void CPetControl::resetActiveNPC() { + _activeNPC = nullptr; + _activeNPCName = ""; +} + +PetArea CPetControl::setArea(PetArea newArea) { + if (newArea == _currentArea || !isAreaActive()) + return _currentArea; + + // Signal the currently active area that it's being left + _sections[_currentArea]->leave(); + + // Change the current area + PetArea oldArea = _currentArea; + _frame.setArea(newArea); + _currentArea = newArea; + + // Signal to the new view that it's been activated + _sections[_currentArea]->enter(oldArea); + + makeDirty(); + return newArea; +} + +void CPetControl::hideCursor() { + _sections[_currentArea]->hideCursor(); +} + +void CPetControl::showCursor() { + _sections[_currentArea]->showCursor(); +} + +void CPetControl::highlightGlyph(int id) { + _sections[_currentArea]->highlight(id); +} + +void CPetControl::setRemoteTarget(CGameObject *item) { + _remoteTarget = item; + if (item) + _remoteTargetName = item->getName(); + else + _remoteTargetName.clear(); +} + +CRoomItem *CPetControl::getHiddenRoom() { + if (!_hiddenRoom) + _hiddenRoom = CGameObject::getHiddenRoom(); + + return _hiddenRoom; +} + +CGameObject *CPetControl::getHiddenObject(const CString &name) { + CRoomItem *room = getHiddenRoom(); + return room ? static_cast<CGameObject *>(findUnder(room, name)) : nullptr; +} + +bool CPetControl::containsPt(const Common::Point &pt) const { + return _drawBounds.contains(pt); +} + +bool CPetControl::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!containsPt(msg->_mousePos) || isInputLocked()) + return false; + + bool result = false; + if (isAreaActive()) + result = _frame.MouseButtonDownMsg(msg); + + if (!result) { + result = _sections[_currentArea]->MouseButtonDownMsg(msg); + } + + makeDirty(); + return result; +} + +bool CPetControl::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!containsPt(msg->_mousePos) || isInputLocked()) + return false; + + return _sections[_currentArea]->MouseDragStartMsg(msg); +} + +bool CPetControl::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + return _sections[_currentArea]->MouseDragMoveMsg(msg); +} + +bool CPetControl::MouseDragEndMsg(CMouseDragEndMsg *msg) { + return _sections[_currentArea]->MouseDragEndMsg(msg); +} + +bool CPetControl::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!containsPt(msg->_mousePos) || isInputLocked()) + return false; + + bool result = false; + if (isAreaActive()) + result = _frame.MouseButtonUpMsg(msg); + + if (!result) + result = _sections[_currentArea]->MouseButtonUpMsg(msg); + + makeDirty(); + return result; +} + +bool CPetControl::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + if (!containsPt(msg->_mousePos) || isInputLocked()) + return false; + + return _sections[_currentArea]->MouseDoubleClickMsg(msg); +} + +bool CPetControl::KeyCharMsg(CKeyCharMsg *msg) { + if (isInputLocked()) + return false; + + return _sections[_currentArea]->KeyCharMsg(msg); +} + +bool CPetControl::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + if (isInputLocked()) + return false; + + bool result = _sections[_currentArea]->VirtualKeyCharMsg(msg); + + if (!result) { + switch (msg->_keyState.keycode) { + case Common::KEYCODE_F1: + result = true; + setArea(PET_INVENTORY); + break; + case Common::KEYCODE_F2: + result = true; + setArea(PET_CONVERSATION); + break; + case Common::KEYCODE_F3: + result = true; + setArea(PET_REMOTE); + break; + case Common::KEYCODE_F4: + result = true; + setArea(PET_ROOMS); + break; + case Common::KEYCODE_F5: + result = true; + setArea(PET_REAL_LIFE); + break; + default: + break; + } + } + + return result; +} + +bool CPetControl::TimerMsg(CTimerMsg *msg) { + warning("TODO: CPetControl::CTimerMsg"); + return true; +} + +void CPetControl::drawSquares(CScreenManager *screenManager, int count) { + _frame.drawSquares(screenManager, count); +} + +CGameObject *CPetControl::dragEnd(const Point &pt) const { + return _currentArea == PET_INVENTORY ? _inventory.dragEnd(pt) : nullptr; +} + +bool CPetControl::checkDragEnd(CGameObject *item) const { + return _sections[_currentArea]->checkDragEnd(item); +} + +void CPetControl::displayMessage(const CString &msg) const { + _sections[_currentArea]->displayMessage(msg); +} + +CGameObject *CPetControl::getFirstObject() const { + return static_cast<CGameObject *>(getFirstChild()); +} + +CGameObject *CPetControl::getNextObject(CGameObject *prior) const { + if (!prior || prior->getParent() != this) + return nullptr; + + return static_cast<CGameObject *>(prior->getNextSibling()); +} + +void CPetControl::addToInventory(CGameObject *item) { + item->detach(); + + if (item->getName() == "CarryParcel") { + CCarry *child = static_cast<CCarry *>(getLastChild()); + if (child) + child->detach(); + + item->petMoveToHiddenRoom(); + if (!child) + return; + + item = child; + } + + item->addUnder(this); + _inventory.itemsChanged(); + + setArea(PET_INVENTORY); + if (_currentArea == PET_INVENTORY) + _inventory.highlightItem(item); + + makeDirty(); + CPETGainedObjectMsg msg; + msg.execute(item); +} + +void CPetControl::removeFromInventory(CGameObject *item, CTreeItem *newParent, + bool refreshUI, bool sendMsg) { + if (item && newParent) { + item->detach(); + item->addUnder(newParent); + + if (refreshUI) + _inventory.itemRemoved(item); + if (sendMsg) { + CPETLostObjectMsg lostMsg; + lostMsg.execute(item); + } + } +} + +void CPetControl::removeFromInventory(CGameObject *item, bool refreshUI, bool sendMsg) { + CViewItem *view = getGameManager()->getView(); + removeFromInventory(item, view, refreshUI, sendMsg); +} + +void CPetControl::invChange(CGameObject *item) { + _inventory.change(item); +} + +void CPetControl::moveToHiddenRoom(CTreeItem *item) { + CRoomItem *room = getHiddenRoom(); + if (room) { + item->detach(); + room->addUnder(item); + } +} + +bool CPetControl::checkNode(const CString &name) { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return true; + if (name == "NULL") + return false; + + CViewItem *view = gameManager->getView(); + if (!view) + return true; + + CNodeItem *node = view->findNode(); + if (!node) + return true; + + CString viewName = view->getName(); + CString nodeName = node->getName(); + CRoomItem *room = getGameManager()->getRoom(); + + if (room) { + CString roomName = room->getName(); + CString newNode; + + if (roomName == "1stClassRestaurant") { + } else if (nodeName == "Lobby Node") { + nodeName = "Node 1"; + } else if (nodeName == "Entrance Node") { + nodeName = "Node 2"; + } else if (nodeName == "MaitreD Node") { + nodeName = "Node 3"; + } else if (nodeName == "Scraliontis Table Standing Node") { + nodeName = "Node 4"; + } else if (nodeName == "Pellerator Node") { + nodeName = "Node 5"; + } else if (nodeName == "SUB Node") { + nodeName = "Node 6"; + } else if (nodeName == "Phonograph Node") { + nodeName = "Node 7"; + } else if (nodeName == "Scraliontis Table Seated Node") { + nodeName = "Node 8"; + } + + if (roomName == "MusicRoom") { + if (nodeName == "Musical Instruments") + nodeName = "Node 1"; + if (nodeName == "Phonograph Node") + nodeName = "Node 2"; + } + } + + CString str = CString::format("%s.%s", nodeName.c_str(), viewName.c_str()); + str = str.right(5); + str.toLowercase(); + + CString nameLower = name; + nameLower.toLowercase(); + + return nameLower.contains(str); +} + +void CPetControl::playSound(int soundNum) { + CTreeItem *player = getHiddenObject("PETSoundPlayer"); + if (player) { + CPETPlaySoundMsg playMsg(soundNum); + playMsg.execute(player); + } +} + +int CPetControl::canSummonBot(const CString &name) { + // If player is the very same view as the NPC, then it's already present + if (isBotInView(name)) + return SUMMON_CAN; + + // Get the room + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return SUMMON_CANT; + CRoomItem *room = gameManager->getRoom(); + if (!room) + return SUMMON_CANT; + + // Query current room to see whether the bot can be summoned to it + CSummonBotQueryMsg queryMsg(name); + return queryMsg.execute(room) ? SUMMON_CAN : SUMMON_CANT; +} + +bool CPetControl::isBotInView(const CString &name) const { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return false; + CViewItem *view = gameManager->getView(); + if (!view) + return false; + + // Iterate to find NPC + for (CTreeItem *child = view->getFirstChild(); child; child = child->scan(view)) { + CGameObject *gameObject = static_cast<CGameObject *>(child); + if (gameObject) { + if (!gameObject->getName().compareToIgnoreCase(name)) + return true; + } + } + + return false; +} + +void CPetControl::summonBot(const CString &name, int val) { + CGameManager *gameManager = getGameManager(); + if (gameManager) { + CRoomItem *room = gameManager->getRoom(); + + if (room) { + CSummonBotMsg summonMsg(name, val); + summonMsg.execute(room); + } + } +} + +void CPetControl::onSummonBot(const CString &name, int val) { + CGameObject *bot = findBot(name, getHiddenRoom()); + if (!bot) { + bot = findBot(name, getRoot()); + } + + if (bot) { + removeFromInventory(bot, false, false); + + COnSummonBotMsg summonMsg(val); + summonMsg.execute(bot); + } +} + +bool CPetControl::dismissBot(const CString &name) { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return false; + CViewItem *view = gameManager->getView(); + if (!view) + return false; + + bool result = false; + CDismissBotMsg dismissMsg; + for (CTreeItem *treeItem = view->getFirstChild(); treeItem; + treeItem = treeItem->scan(view)) { + if (!treeItem->getName().compareToIgnoreCase(name)) + dismissMsg.execute(treeItem); + else + result = true; + } + + return result; +} + +bool CPetControl::isDoorOrBellbotPresent() const { + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return false; + CViewItem *view = gameManager->getView(); + if (!view) + return false; + + for (CTreeItem *treeItem = view->getFirstChild(); treeItem; + treeItem = treeItem->scan(view)) { + CString name = treeItem->getName(); + if (static_cast<CGameObject *>(treeItem) && + (name.contains("Doorbot") || name.contains("BellBot"))) + return true; + } + + return false; +} + +void CPetControl::startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target) { + stopPetTimer(timerIndex); + _timers[timerIndex]._id = addTimer(timerIndex, firstDuration, duration); + _timers[timerIndex]._target = target; + setTimerPersisent(_timers[timerIndex]._id, false); +} + +void CPetControl::stopPetTimer(uint timerIndex) { + if (_timers[timerIndex]._target) { + stopTimer(_timers[timerIndex]._id); + _timers[timerIndex]._target = nullptr; + } +} + +void CPetControl::setTimerPersisent(int id, bool flag) { + getGameManager()->setTimerPersisent(id, flag); +} + +CGameObject *CPetControl::findBot(const CString &name, CTreeItem *root) { + for (CTreeItem *item = root; item; item = item->scan(root)) { + if (!item->getName().compareToIgnoreCase(name)) { + CGameObject *obj = static_cast<CGameObject *>(item); + if (obj) + return obj; + } + } + + return nullptr; +} + +bool CPetControl::isSuccUBusActive() const { + if (!_activeNPC) + return false; + + CString name = getName(); + return name.contains("Succubus") || name.contains("Sub"); +} + +void CPetControl::convResetDials(int flag) { + if (flag == 1) + _conversations.resetDials(_activeNPCName); +} + +int CPetControl::getMailDest(const CRoomFlags &roomFlags) const { + if (!roomFlags.isSuccUBusRoomFlags()) + return roomFlags.getPassengerClassNum(); + + return roomFlags.getSuccUBusNum(roomFlags.getSuccUBusRoomName()); +} + +void CPetControl::starsSetButtons(int val1, int val2) { + _starfield.setButtons(val1, val2); + if (_currentArea == PET_STARFIELD) + _starfield.makePetDirty(); +} + +void CPetControl::starsSetReference(bool hasRef) { + _starfield.setHasReference(hasRef); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h new file mode 100644 index 0000000000..a86d110458 --- /dev/null +++ b/engines/titanic/pet_control/pet_control.h @@ -0,0 +1,574 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_CONTROL_H +#define TITANIC_PET_CONTROL_H + +#include "titanic/core/game_object.h" +#include "titanic/core/node_item.h" +#include "titanic/core/room_item.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/pet_control/pet_conversations.h" +#include "titanic/pet_control/pet_frame.h" +#include "titanic/pet_control/pet_inventory.h" +#include "titanic/pet_control/pet_message.h" +#include "titanic/pet_control/pet_starfield.h" +#include "titanic/pet_control/pet_real_life.h" +#include "titanic/pet_control/pet_remote.h" +#include "titanic/pet_control/pet_rooms.h" +#include "titanic/room_flags.h" + +namespace Titanic { + +enum SummonResult { SUMMON_CANT = 0, SUMMON_PRESENT = 1, SUMMON_CAN = 2 }; + +class CPetControl : public CGameObject { + DECLARE_MESSAGE_MAP; + struct PetEventInfo { + int _id; + CPetSection *_target; + PetEventInfo() : _id(0), _target(nullptr) {} + }; +private: + int _inputLockCount; + int _areaLockCount; + int _areaChangeType; + CPetSection *_sections[7]; + CPetConversations _conversations; + CPetInventory _inventory; + CPetStarfield _starfield; + CPetRemote _remote; + CPetRooms _rooms; + CPetRealLife _realLife; + CPetMessage _message; + CPetFrame _frame; + CString _activeNPCName; + CString _remoteTargetName; + CRoomItem *_hiddenRoom; + Rect _drawBounds; + PetEventInfo _timers[2]; +private: + /** + * Returns true if the control is in a valid state + */ + bool isValid(); + + /** + * Loads data for the individual areas + */ + void loadAreas(SimpleFile *file, int param); + + /** + * Saves data for the individual areas + */ + void saveAreas(SimpleFile *file, int indent); + + /** + * Called at the end of the post game-load handling + */ + void loaded(); + + /** + * Returns true if the draw bounds contains the specified point + */ + bool containsPt(const Common::Point &pt) const; + + /** + * Checks whether a designated NPC in present in the current view + */ + bool isBotInView(const CString &name) const; + + /** + * Find a bot under a given root + */ + CGameObject *findBot(const CString &name, CTreeItem *root); + + /** + * Flags whether the timer will be persisent across save & loads + */ + void setTimerPersisent(int id, bool flag); +protected: + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); + bool KeyCharMsg(CKeyCharMsg *msg); + bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + bool TimerMsg(CTimerMsg *msg); +public: + PetArea _currentArea; + CTreeItem *_activeNPC; + CGameObject *_remoteTarget; +public: + CLASSDEF; + CPetControl(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Gets the bounds occupied by the item + */ + virtual Rect getBounds() const; + + /** + * Setups the sections within the PET + */ + void setup(); + + /** + * Called after loading a game has finished + */ + void postLoad(); + + /** + * Called when a new node is entered + */ + void enterNode(CNodeItem *node); + + /** + * Called when a new room is entered + */ + void enterRoom(CRoomItem *room); + + /** + * Called to reset the remote target + */ + void resetRemoteTarget(); + + /** + * Set the remote target + */ + void setRemoteTarget(CGameObject *item); + + /** + * Sets the currently viewed area within the PET + */ + PetArea setArea(PetArea newSection); + + /** + * Hides the text cursor in the current section, if applicable + */ + void hideCursor(); + + /** + * Shows the text cursor in the current section, if applicable + */ + void showCursor(); + + /** + * Highlights a glyph item in the currently active section, if applicable + */ + void highlightGlyph(int id); + + + /** + * Returns a game object used by the PET by name from within the + * special hidden room container + */ + CGameObject *getHiddenObject(const CString &name); + + /** + * Returns a reference to the special hidden room container + */ + CRoomItem *getHiddenRoom(); + + /** + * Draws squares for showing glyphs inside + */ + void drawSquares(CScreenManager *screenManager, int count); + + /** + * Returns true if the point is within the PET's draw bounds + */ + bool contains(const Point &pt) const { + return _drawBounds.contains(pt); + } + + /** + * Handles drag ends within the PET + */ + CGameObject *dragEnd(const Point &pt) const; + + /** + * Handles checking when a drag-drop operation ends + */ + bool checkDragEnd(CGameObject *item) const; + + /** + * Display a message + */ + void displayMessage(const CString &msg) const; + + /** + * Get the first game object stored in the PET + */ + CGameObject *getFirstObject() const; + + /** + * Get the next game object stored in the PET following + * the passed game object + */ + CGameObject *getNextObject(CGameObject *prior) const; + + /** + * Adds an item to the PET inventory + */ + void addToInventory(CGameObject *item); + + /** + * Remove an item from the inventory + */ + void removeFromInventory(CGameObject *item, CTreeItem *newParent, + bool refreshUI = true, bool sendMsg = true); + + /** + * Remove an item from the inventory + */ + void removeFromInventory(CGameObject *item, bool refreshUI = true, bool sendMsg = true); + + /** + * Called when the status of an item in the inventory has changed + */ + void invChange(CGameObject *item); + + /** + * Moves a tree item from it's original position to be under the hidden room + */ + void moveToHiddenRoom(CTreeItem *item); + + /** + * Sets a change for the PET Area's glyphs. Only applicable when + * the Inventory is the active tab + */ + void setAreaChangeType(int changeType) { _areaChangeType = changeType; } + + bool checkNode(const CString &name); + + /** + * Play a sound + */ + void playSound(int soundNum); + + /** + * Check whether an NPC can be summoned + */ + int canSummonBot(const CString &name); + + /** + * Summon an NPC to the player + */ + void summonBot(const CString &name, int val); + + /** + * Summon a bot to the player + */ + void onSummonBot(const CString &name, int val); + + /** + * Dismiss an NPC + */ + bool dismissBot(const CString &name); + + /** + * Returns true if Doorbot or Bellbot present + */ + bool isDoorOrBellbotPresent() const; + + /** + * Start a timer for a Pet Area + */ + void startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target); + + /** + * Stop a timer + */ + void stopPetTimer(uint timerIndex); + + /** + * Returns true if all input is currently locked (disabled) + */ + bool isInputLocked() const { return _inputLockCount > 0; } + + /** + * Increments the input locked count + */ + void incInputLocks() { ++_inputLockCount; } + + /** + * Decremenst the input locked count + */ + void decInputLocks() { --_inputLockCount; } + + /** + * Returns true if the PET is currently unlocked + */ + bool isAreaActive() const { return _areaLockCount == 0; } + + /** + * Increment the number of PET area (tab) locks + */ + void incAreaLocks() { ++_areaLockCount; } + + /** + * Decrement the number of PET area (tab) locks + */ + void decAreaLocks() { + _areaLockCount = MAX(_areaLockCount - 1, 0); + } + + bool isSuccUBusActive() const; + + /*--- CPetConversations methods ---*/ + + /** + * Sets the active NPC + */ + void setActiveNPC(const CString &name) { + _conversations.setActiveNPC(name); + } + + /** + * Sets the actie NPC + */ + void setActiveNPC(CTrueTalkNPC *npc); + + /** + * Refresh the currently active NPC + */ + void refreshNPC(); + + /** + * Resets the Active NPC + */ + void resetActiveNPC(); + + /** + * Resets NPC in conversations + */ + void convResetNPC() { + _conversations.resetNPC(); + } + + /** + * Resets the conversation dials back to 0 position + */ + void resetDials0() { _conversations.resetDials0(); } + + /** + * Resets the dial display in the conversation tab to reflect new values + */ + void convResetDials(int flag = 1); + + /** + * Adds a line to the conversation log + */ + void convAddLine(const CString &line) { + _conversations.addLine(line); + } + + /*--- CPetRooms methods ---*/ + + /** + * Gives the player a new assigned room in the specified passenger class + */ + void reassignRoom(int passClassNum) { + _rooms.reassignRoom(passClassNum); + } + + /** + * Change the current location passenger class + */ + bool changeLocationClass(int newClassNum) { + return _rooms.changeLocationClass(newClassNum); + } + + /** + * Returns true if the Rooms list has a room with the given flags + */ + bool hasRoomFlags() const { + return _rooms.hasRoomFlags(getRoomFlags()); + } + + uint getRoomFlags() const { + return _rooms.getRoomFlags(); + } + + /** + * Set the current elevator number to use for room glyphs + */ + void setRoomsElevatorNum(int elevNum) { + _rooms.setElevatorNum(elevNum); + } + + /** + * Get the current elevator number used by room glyphs + */ + int getRoomsElevatorNum() const { + return _rooms.getElevatorNum(); + } + + /** + * Set the current floor number to use for room glyphs + */ + void setRoomsFloorNum(int floorNum) { + _rooms.setFloorNum(floorNum); + } + + /** + * Get the current floor number used by room glyphs + */ + int getRoomsFloorNum() const { + return _rooms.getFloorNum(); + } + + /** + * Set the current room number to use for room glyphs + */ + void setRoomsRoomNum(int roomNum) { + _rooms.setRoomNum(roomNum); + } + + /** + * Get the current floor number used by room glyphs + */ + int getRoomsRoomNum() const { + return _rooms.getRoomNum(); + } + + /** + * Sets the entry number for arriving at the well + */ + void setRoomsWellEntry(int entryNum) { + _rooms.setWellEntry(entryNum); + } + + /** + * Gets the entry number used when last arriving at the well + */ + int getRoomsWellEntry() const { + return _rooms.getWellEntry(); + } + + void setRooms1CC(int v) { + _rooms.set1CC(v); + } + int getRooms1CC() const { + return _rooms.get1CC(); + } + + /** + * Reset the highlight + */ + void resetRoomsHighlight() { + _rooms.resetHighlight(); + } + + int getAssignedRoomFlags() const { + return _rooms.getAssignedRoomFlags(); + } + + uint getSpecialRoomFlags(const CString &name) { + return CRoomFlags::getSpecialRoomFlags(name); + } + + /** + * Get mail destination given the specified flags + */ + int getMailDest(const CRoomFlags &roomFlags) const; + + bool testRooms5(uint roomFlags) { + return CRoomFlags(roomFlags).not5(); + } + + /** + * Returns the room number for the player's currently assigned room + */ + int getAssignedRoomNum() const { + return _rooms.getAssignedRoomNum(); + } + + /** + * Returns the floor number for the player's currently assigned room + */ + int getAssignedFloorNum() const { + return _rooms.getAssignedFloorNum(); + } + + /** + * Returns the elevator number for the player's currently assigned room + */ + int getAssignedElevatorNum() const { + return _rooms.getAssignedElevatorNum(); + } + + void setRooms1D4(int val) { + _rooms.set1D4(val); + } + + bool isRoom59706() const { + return CRoomFlags(getRoomFlags()).is59706(); + } + + /** + * Returns true if the passed room flags indicate the room has a succubus + */ + bool isSuccUBusRoom(const CRoomFlags &roomFlags) { + return roomFlags.isSuccUBusRoomFlags(); + } + + /** + * Called with a phonograph action for Send, Receive, or Record + */ + void phonographAction(const CString &action) { + // Original had some code that had no effect + } + + /** + * Sets the status buttons for the starfield control + */ + void starsSetButtons(int val1, int val2); + + /** + * Set whether the user has the galactic reference material + */ + void starsSetReference(bool hasRef); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_CONTROL_H */ diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp new file mode 100644 index 0000000000..dc096afcfe --- /dev/null +++ b/engines/titanic/pet_control/pet_conversations.cpp @@ -0,0 +1,579 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_conversations.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/game_manager.h" + +namespace Titanic { + +CPetConversations::CPetConversations() : CPetSection(), + _logChanged(false), _field418(0), _npcNum(-1), + _rect1(22, 352, 598, 478) { + Rect logRect(85, 18, 513, 87); + logRect.translate(20, 350); + _log.setBounds(logRect); + _log.resize(50); + _log.setHasBorder(false); + _log.setColor(getColor(2)); + _log.setup(); + _log.addLine("Welcome to your PET v1.0a"); + + Rect inputRect(85, 95, 513, 135); + inputRect.translate(20, 350); + _textInput.setBounds(inputRect); + _textInput.setHasBorder(false); + _textInput.resize(2); + _textInput.setMaxCharsPerLine(74); + _textInput.setColor(getColor(0)); + _textInput.setup(); + + _npcLevels[0] = _npcLevels[1] = _npcLevels[2] = 0; +} + +bool CPetConversations::setup(CPetControl *petControl) { + if (petControl && setupControl(petControl)) + return reset(); + return false; +} + +bool CPetConversations::reset() { + _dials[0].setup(MODE_UNSELECTED, "3PetDial1", _petControl); + _dials[1].setup(MODE_UNSELECTED, "3PetDial2", _petControl); + _dials[2].setup(MODE_UNSELECTED, "3PetDial3", _petControl); + + _dialBackground.reset("PetDialBack", _petControl); + _scrollUp.reset("PetScrollUp", _petControl); + _scrollDown.reset("PetScrollDown", _petControl); + + _doorBot.reset("PetCallDoorOut", _petControl, MODE_UNSELECTED); + _doorBot.reset("PetCallDoorIn", _petControl, MODE_SELECTED); + _bellBot.reset("PetCallBellOut", _petControl, MODE_UNSELECTED); + _bellBot.reset("PetCallBellIn", _petControl, MODE_SELECTED); + + _indent.reset("PetSmallCharacterIndent", _petControl); + _splitter.reset("PetSplitter", _petControl); + + _npcIcons[0].setup(MODE_UNSELECTED, "3PetSmlDoorbot", _petControl); + _npcIcons[1].setup(MODE_UNSELECTED, "3PetSmlDeskbot", _petControl); + _npcIcons[2].setup(MODE_UNSELECTED, "3PetSmlLiftbot", _petControl); + _npcIcons[3].setup(MODE_UNSELECTED, "3PetSmlParrot", _petControl); + _npcIcons[4].setup(MODE_UNSELECTED, "3PetSmlBarbot", _petControl); + _npcIcons[5].setup(MODE_UNSELECTED, "3PetSmlChatterbot", _petControl); + _npcIcons[6].setup(MODE_UNSELECTED, "3PetSmlBellbot", _petControl); + _npcIcons[7].setup(MODE_UNSELECTED, "3PetSmlMaitreD", _petControl); + _npcIcons[8].setup(MODE_UNSELECTED, "3PetSmlSuccubus", _petControl); + + if (_petControl->getPassengerClass() == 1) { + uint col = getColor(0); + _textInput.setColor(col); + _textInput.setLineColor(0, col); + + // Replace the log colors with new 1st class ones + uint colors1[5], colors2[5]; + copyColors(2, colors1); + copyColors(1, colors2); + _log.remapColors(5, colors1, colors2); + + _log.setColor(getColor(2)); + } + + return true; +} + +void CPetConversations::draw(CScreenManager *screenManager) { + _dialBackground.draw(screenManager); + _splitter.draw(screenManager); + _dials[0].draw(screenManager); + _dials[1].draw(screenManager); + _dials[2].draw(screenManager); + + _indent.draw(screenManager); + _doorBot.draw(screenManager); + _bellBot.draw(screenManager); + _scrollUp.draw(screenManager); + _scrollDown.draw(screenManager); + _log.draw(screenManager); + _textInput.draw(screenManager); + + if (_logChanged) { + int startIndex = _log.getLinesStart(); + if (startIndex >= 0) { + int npcNum = _log.getNPCNum(1, startIndex); + if (npcNum > 0 && npcNum < 10) + _npcNum = npcNum; + } + + _logChanged = false; + } + + if (_npcNum >= 0) + _npcIcons[_npcNum].draw(screenManager); +} + +Rect CPetConversations::getBounds() const { + Rect rect = _dials[0].getBounds(); + rect.combine(_dials[1].getBounds()); + rect.combine(_dials[2].getBounds()); + + return rect; +} + +bool CPetConversations::isValid(CPetControl *petControl) { + return setupControl(petControl); +} + +bool CPetConversations::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_scrollDown.MouseButtonDownMsg(msg->_mousePos)) { + scrollDown(); + return true; + } else if (_scrollUp.MouseButtonDownMsg(msg->_mousePos)) { + scrollUp(); + return true; + } + + return + _doorBot.MouseButtonDownMsg(msg->_mousePos) || + _bellBot.MouseButtonDownMsg(msg->_mousePos); +} + +bool CPetConversations::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (_scrollUp.MouseButtonUpMsg(msg->_mousePos) || + _scrollDown.MouseButtonUpMsg(msg->_mousePos)) + return true; + + if (_doorBot.MouseButtonUpMsg(msg->_mousePos)) { + switch (canSummonBot("DoorBot")) { + case SUMMON_CANT: + _log.addLine("Sadly, it is not possible to summon the DoorBot from this location.", getColor(1)); + break; + case SUMMON_CAN: + summonBot("DoorBot"); + return true; + default: + break; + } + + // Scroll to the bottom of the log + scrollToBottom(); + return true; + } + + if (_bellBot.MouseButtonUpMsg(msg->_mousePos)) { + switch (canSummonBot("BellBot")) { + case SUMMON_CANT: + _log.addLine("Sadly, it is not possible to summon the BellBot from this location.", getColor(1)); + break; + case SUMMON_CAN: + summonBot("BellBot"); + return true; + default: + break; + } + + // Scroll to the bottom of the log + scrollToBottom(); + return true; + } + + return false; +} + +bool CPetConversations::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + return _scrollDown.MouseDoubleClickMsg(msg->_mousePos) + || _scrollUp.MouseDoubleClickMsg(msg->_mousePos); +} + +bool CPetConversations::KeyCharMsg(CKeyCharMsg *msg) { + Common::KeyState keyState; + keyState.ascii = msg->_key; + return handleKey(keyState); +} + +bool CPetConversations::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + return handleKey(msg->_keyState); +} + +void CPetConversations::displayMessage(const CString &msg) { + _log.addLine(msg, getColor(1)); + scrollToBottom(); +} + +void CPetConversations::load(SimpleFile *file, int param) { + _textInput.load(file, param); + _log.load(file, param); + + for (int idx = 0; idx < TOTAL_DIALS; ++idx) + _npcLevels[idx] = file->readNumber(); +} + +void CPetConversations::postLoad() { + reset(); +} + +void CPetConversations::save(SimpleFile *file, int indent) { + _textInput.save(file, indent); + _log.save(file, indent); + + for (int idx = 0; idx < TOTAL_DIALS; ++idx) + file->writeNumberLine(_npcLevels[idx], indent); +} + +void CPetConversations::enter(PetArea oldArea) { + resetDials(); + + if (_petControl && _petControl->_activeNPC) + // Start a timer for the NPC + startNPCTimer(); + + // Show the text cursor + _textInput.showCursor(-2); +} + +void CPetConversations::leave() { + _textInput.hideCursor(); + stopNPCTimer(); +} + +void CPetConversations::timerExpired(int val) { + if (val == 1) { + CPetSection::timerExpired(val); + } else { + CString name = _field418 ? _npcName : getActiveNPCName(); + + for (int idx = 0; idx < TOTAL_DIALS; ++idx) { + if (!_dials[idx].hasActiveMovie()) + updateDial(idx, name); + } + } +} + +void CPetConversations::displayNPCName(CGameObject *npc) { + if (npc) { + displayMessage(CString()); + CString msg = "Talking to "; + CString name = npc->getName(); + int id = 1; + + if (name.contains("Doorbot")) { + msg += "the DoorBot"; + } else if (name.contains("DeskBot")) { + id = 2; + msg += "the DeskBot"; + } else if (name.contains("LiftBot")) { + id = 3; + msg += "a LiftBot"; + } else if (name.contains("Parrot")) { + id = 4; + msg += "the Parrot"; + } else if (name.contains("BarBot")) { + id = 5; + msg += "the BarBot"; + } else if (name.contains("ChatterBot")) { + id = 6; + msg += "a ChatterBot"; + } else if (name.contains("BellBot")) { + id = 7; + msg += "the BellBot"; + } else if (name.contains("Maitre")) { + id = 8; + msg += "the Maitre d'Bot"; + } else if (name.contains("Succubus") || name.contains("Sub")) { + id = 9; + msg += "a Succ-U-Bus"; + } else { + msg += "Unknown"; + } + + _log.setNPC(1, id); + displayMessage(msg); + } +} + +void CPetConversations::setNPC(const CString &name) { + _field418 = 0; + resetDials(name); + startNPCTimer(); +} + +void CPetConversations::resetNPC() { + stopNPCTimer(); + resetDials("0"); +} + +void CPetConversations::showCursor() { + _textInput.showCursor(-2); +} + +void CPetConversations::hideCursor() { + _textInput.hideCursor(); +} + +bool CPetConversations::setupControl(CPetControl *petControl) { + if (petControl) { + _petControl = petControl; + + _dialBackground.setBounds(Rect(0, 0, 21, 130)); + _dialBackground.translate(20, 350); + + const Rect rect1(0, 0, 22, 36); + _dials[0].setBounds(rect1); + _dials[0].translate(20, 359); + _dials[1].setBounds(rect1); + _dials[1].translate(20, 397); + _dials[2].setBounds(rect1); + _dials[2].translate(20, 434); + + const Rect rect2(0, 0, 11, 24); + _scrollUp.setBounds(rect2); + _scrollUp.translate(87, 374); + _scrollDown.setBounds(rect2); + _scrollDown.translate(87, 421); + + const Rect rect3(0, 0, 39, 39); + _doorBot.setBounds(rect3); + _doorBot.translate(546, 372); + _bellBot.setBounds(rect3); + _bellBot.translate(546, 418); + + _indent.setBounds(Rect(0, 0, 37, 70)); + _indent.translate(46, 374); + _splitter.setBounds(Rect(0, 0, 435, 3)); + _splitter.translate(102, 441); + + const Rect rect4(0, 0, 33, 66); + for (int idx = 0; idx < 9; ++idx) { + _npcIcons[idx].setBounds(rect4); + _npcIcons[idx].translate(48, 376); + } + } + + return true; +} + +void CPetConversations::scrollUp() { + _log.scrollUp(CScreenManager::_screenManagerPtr); + if (_petControl) + _petControl->makeDirty(); + _logChanged = true; +} + +void CPetConversations::scrollDown() { + _log.scrollDown(CScreenManager::_screenManagerPtr); + if (_petControl) + _petControl->makeDirty(); + _logChanged = true; +} + +void CPetConversations::scrollUpPage() { + _log.scrollUpPage(CScreenManager::_screenManagerPtr); + if (_petControl) + _petControl->makeDirty(); + _logChanged = true; +} + +void CPetConversations::scrollDownPage() { + _log.scrollDownPage(CScreenManager::_screenManagerPtr); + if (_petControl) + _petControl->makeDirty(); + _logChanged = true; +} + +void CPetConversations::scrollToTop() { + _log.scrollToTop(CScreenManager::_screenManagerPtr); + if (_petControl) + _petControl->makeDirty(); + _logChanged = true; +} + +void CPetConversations::scrollToBottom() { + _log.scrollToBottom(CScreenManager::_screenManagerPtr); + if (_petControl) + _petControl->makeDirty(); + _logChanged = true; +} + +int CPetConversations::canSummonBot(const CString &name) { + return _petControl ? _petControl->canSummonBot(name) : SUMMON_CANT; +} + +void CPetConversations::summonBot(const CString &name) { + if (_petControl) { + if (_petControl->getPassengerClass() >= 4) { + _petControl->displayMessage("Sorry, you must be at least 3rd class before you can summon for help."); + } else { + _petControl->summonBot(name, 0); + } + } +} + +void CPetConversations::startNPCTimer() { + _petControl->startPetTimer(1, 1000, 1000, this); +} + +void CPetConversations::stopNPCTimer() { + _petControl->stopPetTimer(1); +} + +TTnpcScript *CPetConversations::getNPCScript(const CString &name) const { + if (name.empty() || !_petControl) + return nullptr; + CGameManager *gameManager = _petControl->getGameManager(); + if (!gameManager) + return nullptr; + CTrueTalkManager *trueTalk = gameManager->getTalkManager(); + if (!trueTalk) + return nullptr; + + return trueTalk->getTalker(name); +} + +bool CPetConversations::handleKey(const Common::KeyState &keyState) { + switch (keyState.keycode) { + case Common::KEYCODE_UP: + case Common::KEYCODE_KP8: + scrollUp(); + break; + case Common::KEYCODE_DOWN: + case Common::KEYCODE_KP2: + scrollDown(); + break; + case Common::KEYCODE_PAGEUP: + case Common::KEYCODE_KP9: + scrollUpPage(); + break; + case Common::KEYCODE_PAGEDOWN: + case Common::KEYCODE_KP3: + scrollDownPage(); + break; + case Common::KEYCODE_HOME: + case Common::KEYCODE_KP7: + scrollToTop(); + break; + case Common::KEYCODE_END: + case Common::KEYCODE_KP1: + scrollToBottom(); + break; + default: + if (keyState.ascii > 0 && keyState.ascii) { + if (_textInput.handleKey(keyState.ascii)) + // Text line finished, so process line + textLineEntered(_textInput.getText()); + } + return true; + } + + return false; +} + +void CPetConversations::textLineEntered(const CString &textLine) { + if (textLine.empty() || !_petControl) + return; + + if (_petControl->_activeNPC) { + _log.addLine("- " + textLine, getColor(0)); + + CTextInputMsg inputMsg(textLine, ""); + inputMsg.execute(_petControl->_activeNPC); + + if (!inputMsg._response.empty()) + _log.addLine(inputMsg._response); + } else { + _log.addLine("There is no one here to talk to", getColor(1)); + } + + // Clear input line and scroll log down to end to show response + _textInput.setup(); + scrollToBottom(); +} + +void CPetConversations::setActiveNPC(const CString &name) { + _npcName = name; + _field418 = 1; + resetDials(); + startNPCTimer(); +} + +void CPetConversations::updateDial(uint dialNum, const CString &npcName) { + TTnpcScript *script = getNPCScript(npcName); + uint newLevel = getDialLevel(dialNum, script); + npcDialChange(dialNum, _npcLevels[dialNum], newLevel); + _npcLevels[dialNum] = newLevel; +} + +uint CPetConversations::getDialLevel(uint dialNum, TTnpcScript *script, int v) { + bool flag = v != 0; + + if (!script) + return 0; + else + return MAX(script->getDialLevel(dialNum, flag), 15); +} + +void CPetConversations::npcDialChange(uint dialNum, int oldLevel, int newLevel) { + const uint range1[2] = { 0, 21 }; + const uint range2[2] = { 22, 43 }; + + if (newLevel != oldLevel) { + uint src = range1[0], dest = range1[1]; + if (oldLevel < newLevel) { + src = range2[0]; + dest = range2[1]; + } + + int64 val1 = (oldLevel * dest) + (100 - oldLevel) * src; + uint startFrame = val1 / 100; + + int64 val2 = (newLevel * dest) + (100 - newLevel) * src; + uint endFrame = val2 / 100; + + if (startFrame != endFrame) + _dials[dialNum].playMovie(startFrame, endFrame); + } +} + +void CPetConversations::resetDials() { + resetDials(getActiveNPCName()); +} + +void CPetConversations::resetDials(const CString &name) { + TTnpcScript *script = getNPCScript(name); + + for (int idx = 0; idx < TOTAL_DIALS; ++idx) { + uint oldLevel = _npcLevels[idx]; + uint newLevel = getDialLevel(idx, script); + npcDialChange(idx, oldLevel, newLevel); + _npcLevels[idx] = newLevel; + } +} + +void CPetConversations::resetDials0() { + stopNPCTimer(); + resetDials("0"); +} + +void CPetConversations::addLine(const CString &line) { + _log.addLine(line); + scrollToBottom(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h new file mode 100644 index 0000000000..9e8b093d62 --- /dev/null +++ b/engines/titanic/pet_control/pet_conversations.h @@ -0,0 +1,267 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_CONVERSATIONS_H +#define TITANIC_PET_CONVERSATIONS_H + +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_text.h" +#include "titanic/pet_control/pet_gfx_element.h" +#include "titanic/true_talk/true_talk_manager.h" + +namespace Titanic { + +#define TOTAL_DIALS 3 + +class CPetConversations : public CPetSection { +private: + CPetGfxElement _scrollUp; + CPetGfxElement _scrollDown; + CPetGfxElement _dialBackground; + CPetGfxElement _dials[TOTAL_DIALS]; + uint _npcLevels[TOTAL_DIALS]; + CPetGfxElement _val4; + CPetGfxElement _val5; + CPetGfxElement _indent; + Rect _rect1; + CPetGfxElement _doorBot; + CPetGfxElement _bellBot; + CPetGfxElement _splitter; + CPetGfxElement _npcIcons[9]; + int _npcNum; + CPetText _log; + CPetText _textInput; + bool _logChanged; + int _field418; + CString _npcName; +private: + /** + * Sets up the control + */ + bool setupControl(CPetControl *petControl); + + /** + * Scroll up the conversation log + */ + void scrollUp(); + + /** + * Scroll down the conversation log + */ + void scrollDown(); + + /** + * Scroll up one page in the conversation log + */ + void scrollUpPage(); + + /** + * Scroll down one page in the conversation log + */ + void scrollDownPage(); + + /** + * Scroll to the top of the conversation log + */ + void scrollToTop(); + + /** + * Scroll to the bottom of the conversation log + */ + void scrollToBottom(); + + /** + * Check whether an NPC can be summoned + */ + int canSummonBot(const CString &name); + + /** + * Summon an NPC + */ + void summonBot(const CString &name); + + /** + * Starts the NPC timer + */ + void startNPCTimer(); + + /** + * Stops the NPC timer + */ + void stopNPCTimer(); + + /** + * Get the TrueTalk script associated with a given NPC + */ + TTnpcScript *getNPCScript(const CString &name) const; + + /** + * Handle a keypress + */ + bool handleKey(const Common::KeyState &keyState); + + /** + * Handles an entered text line + */ + void textLineEntered(const CString &textLine); + + /** + * Updates one of the dials with data from a given NPC + */ + void updateDial(uint dialNum, const CString &npcName); + + /** + * Get a dial level + */ + uint getDialLevel(uint dialNum, TTnpcScript *script, int v = 1); + + /** + * Called when the dial for an NPC is being changed + */ + void npcDialChange(uint dialNum, int oldLevel, int newLevel); +public: + CPetConversations(); + virtual ~CPetConversations() {} + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Reset the section + */ + virtual bool reset(); + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Get the bounds for the section + */ + virtual Rect getBounds() const; + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); + virtual bool KeyCharMsg(CKeyCharMsg *msg); + virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + + /** + * Display a message + */ + virtual void displayMessage(const CString &msg); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param); + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea); + + /** + * Called when a section is being left, to switch to another area + */ + virtual void leave(); + + /** + * Called when a previously set up PET timer expires + */ + virtual void timerExpired(int val); + + /** + * Display a title for an NPC + */ + virtual void displayNPCName(CGameObject *npc); + + /** + * Sets the NPC to use + */ + virtual void setNPC(const CString &name); + + /** + * Resets the active NPC + */ + virtual void resetNPC(); + + /** + * Show the text cursor + */ + virtual void showCursor(); + + /** + * Hide the text cursor + */ + virtual void hideCursor(); + + /** + * Set the active NPC + */ + void setActiveNPC(const CString &name); + + /** + * Resets the dials with the data for the currently active NPC + */ + void resetDials(); + + /** + * Reset the dials with those for a given NPC + */ + void resetDials(const CString &name); + + /** + * Reset the dials to the '0' position + */ + void resetDials0(); + + /** + * Adds a line to the log + */ + void addLine(const CString &line); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_CONVERSATIONS_H */ diff --git a/engines/titanic/pet_control/pet_drag_chev.cpp b/engines/titanic/pet_control/pet_drag_chev.cpp new file mode 100644 index 0000000000..d437d43799 --- /dev/null +++ b/engines/titanic/pet_control/pet_drag_chev.cpp @@ -0,0 +1,76 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_drag_chev.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/messages/messages.h" +#include "titanic/npcs/succubus.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CPetDragChev, CPetGraphic2) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(MouseDragMoveMsg) + ON_MESSAGE(MouseDragEndMsg) +END_MESSAGE_MAP() + +void CPetDragChev::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic2::save(file, indent); +} + +void CPetDragChev::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic2::load(file); +} + +bool CPetDragChev::MouseDragStartMsg(CMouseDragStartMsg *msg) { + getName(); + return checkStartDragging(msg); +} + +bool CPetDragChev::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + dragMove(msg->_mousePos); + return true; +} + +bool CPetDragChev::MouseDragEndMsg(CMouseDragEndMsg *msg) { + if (msg->_dropTarget) { + CSuccUBus *succubus = static_cast<CSuccUBus *>(msg->_dropTarget); + + if (succubus) { + CSetChevRoomBits chevMsg(_id); + chevMsg.execute(succubus); + } else { + CPetControl *petControl = getPetControl(); + if (petControl && petControl->contains(msg->_mousePos) + && msg->_mousePos.x < 528) { + if (petControl->checkDragEnd(this)) + petMoveToHiddenRoom(); + } + } + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_drag_chev.h b/engines/titanic/pet_control/pet_drag_chev.h new file mode 100644 index 0000000000..9f4a6f0dc9 --- /dev/null +++ b/engines/titanic/pet_control/pet_drag_chev.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_DRAG_CHEV_H +#define TITANIC_PET_DRAG_CHEV_H + +#include "titanic/pet_control/pet_graphic2.h" + +namespace Titanic { + +class CPetDragChev : public CPetGraphic2 { + DECLARE_MESSAGE_MAP; +protected: + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + bool MouseDragEndMsg(CMouseDragEndMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_DRAG_CHEV_H */ diff --git a/engines/titanic/pet_control/pet_element.cpp b/engines/titanic/pet_control/pet_element.cpp new file mode 100644 index 0000000000..c5e1a6ea9c --- /dev/null +++ b/engines/titanic/pet_control/pet_element.cpp @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/pet_control/pet_element.h" +#include "titanic/core/game_object.h" + +namespace Titanic { + +CPetElement::CPetElement() : _mode(MODE_UNSELECTED) {} + +Rect CPetElement::getBounds() const { + return Rect(); +} + +bool CPetElement::MouseButtonDownMsg(const Point &pt) { + bool result = _bounds.contains(pt); + if (result) + setMode(MODE_SELECTED); + return result; +} + +bool CPetElement::MouseButtonUpMsg(const Point &pt) { + bool result = _bounds.contains(pt); + if (result) + setMode(MODE_UNSELECTED); + return result; +} + +bool CPetElement::MouseDoubleClickMsg(const Point &pt) const { + return _bounds.contains(pt); +} + +bool CPetElement::MouseMoveMsg(const Point &pt) { + bool result = _bounds.contains(pt); + if (result) + setMode(MODE_FOCUSED); + return result; +} + +bool CPetElement::contains2(const Point &pt) const { + return _bounds.contains(pt); +} + +void CPetElement::playMovie(uint startFrame, uint endFrame) const { + CGameObject *gameObject = getObject(); + + if (gameObject) + gameObject->playMovie(startFrame, endFrame, 0); +} + +void CPetElement::changeStatus(int val) const { + CGameObject *gameObject = getObject(); + + if (gameObject) + gameObject->playMovie(val); +} + +bool CPetElement::hasActiveMovie() const { + CGameObject *gameObject = getObject(); + return gameObject ? gameObject->hasActiveMovie() : false; +} + +void CPetElement::loadFrame(int frameNumber) { + CGameObject *gameObject = getObject(); + if (gameObject) + gameObject->loadFrame(frameNumber); +} + +int CPetElement::getMovieFrame() const { + CGameObject *gameObject = getObject(); + return gameObject ? gameObject->getMovieFrame() : 0; +} + +void CPetElement::setMode(PetElementMode newMode) { + if (newMode >= MODE_UNSELECTED && newMode <= MODE_FOCUSED) + changeMode(newMode); +} + +void CPetElement::setSelected(bool flag) { + if (flag) + changeMode(MODE_SELECTED); + else + changeMode(MODE_UNSELECTED); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h new file mode 100644 index 0000000000..bbf3e83537 --- /dev/null +++ b/engines/titanic/pet_control/pet_element.h @@ -0,0 +1,154 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_ELEMENT_H +#define TITANIC_PET_ELEMENT_H + +#include "titanic/support/simple_file.h" +#include "titanic/support/string.h" +#include "titanic/core/link_item.h" +#include "titanic/messages/mouse_messages.h" + +namespace Titanic { + +enum PetElementMode { MODE_UNSELECTED = 0, MODE_SELECTED = 1, MODE_FOCUSED = 2 }; + +class CGameObject; +class CPetControl; + +class CPetElement { +protected: + Rect _bounds; + PetElementMode _mode; +public: + CPetElement(); + virtual ~CPetElement() {} + + /** + * Sets up the element + */ + virtual void setup(PetElementMode mode, const CString &name, + CPetControl *petControl) {} + + /** + * Reset the element + */ + virtual void reset(const CString &name, CPetControl *petControl, PetElementMode mode) {} + + /** + * Draw the item + */ + virtual void draw(CScreenManager *screenManager) {} + + /** + * Draw the item + */ + virtual void draw(CScreenManager *screenManager, const Point &destPos) {} + + /** + * Get the bounds for the element + */ + virtual Rect getBounds() const; + + /** + * Handles processing mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles processing mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Handles processing mouse button double click messages + */ + virtual bool MouseDoubleClickMsg(const Point &pt) const; + + /** + * Handles processing mouse move messages + */ + virtual bool MouseMoveMsg(const Point &pt); + + /** + * Returns whether the passed point falls inside the item + */ + virtual bool contains2(const Point &pt) const; + + /** + * Plays back a range of frames in the loaded video file for the element + */ + virtual void playMovie(uint startFrame, uint endFrame) const; + + /** + * Change the status of the associated object + */ + virtual void changeStatus(int newStatus) const; + + /** + * Returns true if the object associated with the item has an active movie + */ + virtual bool hasActiveMovie() const; + + /** + * Loads a frame + */ + virtual void loadFrame(int frameNumber); + + /** + * Get the current frame + */ + virtual int getMovieFrame() const; + + /** + * Get the game object associated with this item + */ + virtual CGameObject *getObject() const { return nullptr; } + + virtual void changeMode(PetElementMode newMode) { _mode = newMode; } + + void setMode(PetElementMode mode); + + /** + * Set whether the element is selected + */ + void setSelected(bool flag); + + /** + * Set the bounds for the element + */ + void setBounds(const Rect &r) { _bounds = r; } + + /** + * Translate the position of the element + */ + void translate(int deltaX, int deltaY) { _bounds.translate(deltaX, deltaY); } + + /** + * Translate the position of the element + */ + void translate(const Point &delta) { _bounds.translate(delta.x, delta.y); } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_ELEMENT_H */ diff --git a/engines/titanic/pet_control/pet_frame.cpp b/engines/titanic/pet_control/pet_frame.cpp new file mode 100644 index 0000000000..bc1a8e93b6 --- /dev/null +++ b/engines/titanic/pet_control/pet_frame.cpp @@ -0,0 +1,154 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_frame.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +static const PetArea PET_AREAS[6] = { + PET_CONVERSATION, PET_INVENTORY, PET_REMOTE, + PET_ROOMS, PET_REAL_LIFE, PET_STARFIELD +}; + +CPetFrame::CPetFrame() : CPetSection() { +} + +bool CPetFrame::setup(CPetControl *petControl) { + if (setPetControl(petControl)) + return reset(); + return false; +} + +bool CPetFrame::reset() { + if (_petControl) { + _background.reset("PetBackground", _petControl, MODE_UNSELECTED); + _modeBackground.reset("PetModeBackground", _petControl, MODE_UNSELECTED); + + for (int idx = 0; idx < 5; ++idx) { + CString resName = Common::String::format("PetMode%d", idx + 1); + _modeButtons[idx].reset(resName, _petControl, MODE_SELECTED); + } + + for (int idx = 0; idx < 6; ++idx) { + CString resName = Common::String::format("3Pettitle%d", idx + 1); + _titles[idx].reset(resName, _petControl, MODE_UNSELECTED); + } + + for (int idx = 0; idx < TOTAL_GLYPHS; ++idx) { + CString resName = Common::String::format("PetIndent%d", idx + 1); + _squares[idx].reset(resName, _petControl, MODE_UNSELECTED); + } + } + + return true; +} + +bool CPetFrame::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + for (int idx = 0; idx < 5; ++idx) { + if (_modeButtons[idx].MouseButtonUpMsg(msg->_mousePos)) { + _petControl->setArea(PET_AREAS[idx]); + resetArea(); + _modeButtons[idx].setMode(MODE_SELECTED); + return true; + } + } + + return false; +} + +bool CPetFrame::isValid(CPetControl *petControl) { + bool result = setPetControl(petControl); + if (result) { + _modeButtons[PET_AREAS[0]].setMode(MODE_UNSELECTED); + _modeButtons[PET_AREAS[4]].setMode(MODE_SELECTED); + } + + return result; +} + +void CPetFrame::postLoad() { + reset(); +} + +bool CPetFrame::setPetControl(CPetControl *petControl) { + if (petControl) { + _petControl = petControl; + + // Set the bounds of the individual elements + _background.setBounds(Rect(20, 350, 620, 480)); + _modeBackground.setBounds(Rect(590, 365, 611, 467)); + + // Squares used for holding glyphs in various tabs + Rect r(35, 373, 91, 429); + for (int idx = 0, xp = 0; idx < TOTAL_GLYPHS; ++idx, xp += 70) { + _squares[idx].setBounds(r); + _squares[idx].translate(xp, 0); + } + + // Draw the mode buttons vertically on the right edge of the PET + r = Rect(590, 365, 606, 381); + const int YLIST[] = { 7, 27, 45, 66, 84 }; + for (int idx = 0; idx < 5; ++idx) { + _modeButtons[idx].setBounds(r); + _modeButtons[idx].translate(4, YLIST[idx]); + } + _modeButtons[PET_AREAS[0]].setMode(MODE_SELECTED); + + const int XLIST[] = { 73, 54, 85, 109, 38, 71 }; + for (int idx = 0; idx < 6; ++idx) { + _titles[idx].setBounds(Rect(0, 0, 110, 11)); + _titles[idx].translate(600 - XLIST[idx], 471); + } + } + + return true; +} + +void CPetFrame::setArea(PetArea newArea) { + resetArea(); + if (newArea < PET_MESSAGE) + _modeButtons[PET_AREAS[newArea]].setMode(MODE_SELECTED); +} + +void CPetFrame::resetArea() { + for (int idx = 0; idx < 6; ++idx) + _modeButtons[idx].setMode(MODE_UNSELECTED); +} + +void CPetFrame::drawFrame(CScreenManager *screenManager) { + _background.draw(screenManager); + _modeBackground.draw(screenManager); + + for (int idx = 0; idx < 5; ++idx) + _modeButtons[idx].draw(screenManager); + + _titles[_petControl->_currentArea].draw(screenManager); +} + +void CPetFrame::drawSquares(CScreenManager *screenManager, int count) { + count = CLIP(count, 0, TOTAL_GLYPHS); + for (int idx = 0; idx < count; ++idx) + _squares[idx].draw(screenManager); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_frame.h b/engines/titanic/pet_control/pet_frame.h new file mode 100644 index 0000000000..d8924e83d3 --- /dev/null +++ b/engines/titanic/pet_control/pet_frame.h @@ -0,0 +1,101 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_FRAME_H +#define TITANIC_PET_FRAME_H + +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_gfx_element.h" + +namespace Titanic { + +/** + * This implements the frame and background for the PET display. + * This includes the area buttons and title + */ +class CPetFrame : public CPetSection { +private: + CPetGfxElement _modeButtons[6]; + CPetGfxElement _titles[6]; + CPetGfxElement _modeBackground; + CPetGfxElement _val2; + CPetGfxElement _val3; + CPetGfxElement _background; + CPetGfxElement _squares[7]; +private: + /** + * Called to set the owning PET instance and set some initial state + */ + bool setPetControl(CPetControl *petControl); +public: + CPetFrame(); + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Sets up the section + */ + virtual bool reset(); + + /** + * Handles mouse down messages + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) { return false; } + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + + /** + * Called when the current PET area changes + */ + void setArea(PetArea newArea); + + /** + * Reset the currently selected area + */ + void resetArea(); + + /** + * Draws the PET frame + */ + void drawFrame(CScreenManager *screenManager); + + /** + * Draws the indent + */ + void drawSquares(CScreenManager *screenManager, int count); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_FRAME_H */ diff --git a/engines/titanic/pet_control/pet_gfx_element.cpp b/engines/titanic/pet_control/pet_gfx_element.cpp new file mode 100644 index 0000000000..6022885770 --- /dev/null +++ b/engines/titanic/pet_control/pet_gfx_element.cpp @@ -0,0 +1,103 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/core/game_object.h" +#include "titanic/pet_control/pet_element.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +void CPetGfxElement::setup(PetElementMode mode, const CString &name, + CPetControl *petControl) { + switch (mode) { + case MODE_UNSELECTED: + _object0 = petControl->getHiddenObject(name); + break; + case MODE_SELECTED: + _object1 = petControl->getHiddenObject(name); + break; + case MODE_FOCUSED: + _object2 = petControl->getHiddenObject(name); + break; + default: + break; + } +} + +void CPetGfxElement::reset(const CString &name, CPetControl *petControl, PetElementMode mode) { + if (!petControl) + return; + + CString numString(3); + int classNum = petControl->getPassengerClass(); + + if (classNum >= 1 && classNum <= 3) { + numString = CString(classNum); + } else if (classNum == 4) { + int stateC = petControl->getPriorClass(); + if (stateC == 1) + numString = CString(stateC); + } + + CString resName = numString + name; + setup(mode, resName, petControl); +} + +void CPetGfxElement::draw(CScreenManager *screenManager) { + draw(screenManager, Common::Point(_bounds.left, _bounds.top)); +} + +void CPetGfxElement::draw(CScreenManager *screenManager, const Common::Point &destPos) { + CGameObject *obj = getObject(); + if (!obj) + obj = _object0; + + if (obj) + obj->draw(screenManager, destPos); +} + +Rect CPetGfxElement::getBounds() const { + CGameObject *obj = getObject(); + if (!obj) + obj = _object0; + + if (obj && obj->surfaceHasFrame()) + return _bounds; + else + return Rect(); +} + +CGameObject *CPetGfxElement::getObject() const { + switch (_mode) { + case MODE_UNSELECTED: + return _object0; + case MODE_SELECTED: + return _object1; + case MODE_FOCUSED: + return _object2; + default: + return nullptr; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_gfx_element.h b/engines/titanic/pet_control/pet_gfx_element.h new file mode 100644 index 0000000000..91d9b9ccb2 --- /dev/null +++ b/engines/titanic/pet_control/pet_gfx_element.h @@ -0,0 +1,74 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_GFX_ELEMENT_H +#define TITANIC_PET_GFX_ELEMENT_H + +#include "titanic/pet_control/pet_element.h" + +namespace Titanic { + +class CPetGfxElement: public CPetElement { +public: + CGameObject *_object0; + CGameObject *_object1; + CGameObject *_object2; +public: + CPetGfxElement() : CPetElement(), _object0(nullptr), _object1(nullptr), + _object2(nullptr) {} + + /** + * Setup the element + */ + virtual void setup(PetElementMode mode, const CString &name, + CPetControl *petControl); + + /** + * Reset the element + */ + virtual void reset(const CString &name, CPetControl *petControl, + PetElementMode mode = MODE_UNSELECTED); + + /** + * Draw the item + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Draw the item + */ + virtual void draw(CScreenManager *screenManager, const Common::Point &destPos); + + /** + * Get the bounds for the element + */ + virtual Rect getBounds() const; + + /** + * Get the game object associated with this item + */ + virtual CGameObject *getObject() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_GFX_ELEMENT_H */ diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp new file mode 100644 index 0000000000..bd05342095 --- /dev/null +++ b/engines/titanic/pet_control/pet_glyphs.cpp @@ -0,0 +1,566 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +bool CPetGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + _element.setBounds(Rect(0, 0, 52, 50)); + _owner = owner; + return true; +} + +void CPetGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) { + _element.translate(pt.x, pt.y); + _element.draw(screenManager); + _element.translate(-pt.x, -pt.y); +} + +void CPetGlyph::updateTooltip() { + CPetText *petText = getPetSection()->getText(); + if (petText) { + petText->setColor(getPetSection()->getColor(0)); + getTooltip(petText); + + if (_owner) + getPetSection()->stopTextTimer(); + } +} + +bool CPetGlyph::contains(const Point &delta, const Point &pt) { + translate(delta); + bool result = _element.contains2(pt); + translateBack(delta); + + return result; +} + +CPetSection *CPetGlyph::getPetSection() const { + return _owner ? _owner->getOwner() : nullptr; +} + +CPetControl *CPetGlyph::getPetControl() const { + return _owner ? _owner->getPetControl() : nullptr; +} + +void CPetGlyph::setName(const CString &name, CPetControl *petControl) { + Rect r(0, 0, 52, 52); + _element.setBounds(r); + _element.reset(name, petControl, MODE_UNSELECTED); +} + +bool CPetGlyph::isHighlighted() const { + return _owner->isGlyphHighlighted(this); +} + +/*------------------------------------------------------------------------*/ + +CPetGlyphs::CPetGlyphs() : _firstVisibleIndex(0), _numVisibleGlyphs(TOTAL_GLYPHS), + _highlightIndex(-1), _field1C(-1), _flags(0), + _dragGlyph(nullptr), _owner(nullptr) { +} + +void CPetGlyphs::setNumVisible(int total) { + if (total > 0) + _numVisibleGlyphs = total; +} + +void CPetGlyphs::clear() { + changeHighlight(-1); + destroyContents(); + _firstVisibleIndex = 0; +} + +void CPetGlyphs::setup(int numVisible, CPetSection *owner) { + setNumVisible(numVisible); + _owner = owner; + _selection.setBounds(Rect(0, 0, 76, 76)); + + int buttonsLeft = numVisible * 70 + 21; + + _scrollLeft.setBounds(Rect(0, 0, 31, 15)); + _scrollLeft.translate(buttonsLeft, 373); + _scrollRight.setBounds(Rect(0, 0, 31, 15)); + _scrollRight.translate(buttonsLeft, 413); +} + +void CPetGlyphs::reset() { + if (_owner && _owner->_petControl) { + CPetControl *pet = _owner->_petControl; + + _scrollLeft.reset("PetScrollLeft", pet, MODE_UNSELECTED); + _scrollRight.reset("PetScrollRight", pet, MODE_UNSELECTED); + _selection.reset("PetSelection", pet, MODE_UNSELECTED); + + for (iterator i = begin(); i != end(); ++i) { + (*i)->reset(); + } + } +} + +void CPetGlyphs::enter() { + if (_highlightIndex != -1) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + if (glyph) + glyph->enter(); + } +} + +void CPetGlyphs::leave() { + if (_highlightIndex != -1) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + if (glyph) + glyph->leave(); + } +} + +void CPetGlyphs::draw(CScreenManager *screenManager) { + if (_highlightIndex != -1) { + int index = getHighlightedIndex(_highlightIndex); + if (index != -1) { + Point tempPoint; + Point pt = getPosition(index); + pt -= Point(12, 13); + _selection.translate(pt.x, pt.y); + _selection.draw(screenManager); + _selection.translate(-pt.x, -pt.y); + } + } + + // Iterate through displaying glyphs on the screen + int listSize = size(); + for (int index = 0; index < _numVisibleGlyphs; ++index) { + int itemIndex = getItemIndex(index); + + if (itemIndex >= 0 && itemIndex < listSize) { + Point pt = getPosition(itemIndex); + CPetGlyph *glyph = getGlyph(itemIndex); + + if (glyph) + glyph->drawAt(screenManager, pt, index == _highlightIndex); + } + } + + // Draw scrolling arrows if more than a screen's worth of items are showing + if (listSize > _numVisibleGlyphs || (_flags & GFLAG_16)) { + _scrollLeft.draw(screenManager); + _scrollRight.draw(screenManager); + } + + // Handle secondary highlight + if (_highlightIndex != -1) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + if (glyph) + glyph->draw2(screenManager); + } +} + +Point CPetGlyphs::getPosition(int index) const { + Point tempPoint(37 + index * 70, 375); + return tempPoint; +} + +Rect CPetGlyphs::getRect(int index) const { + Point pt = getPosition(index); + return Rect(pt.x, pt.y, pt.x + 52, pt.y + 52); +} + +void CPetGlyphs::changeHighlight(int index) { + if (index == _highlightIndex) + return; + + if (_highlightIndex >= 0 && (_flags & GFLAG_4)) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + if (glyph) + glyph->unhighlightCurrent(); + } + + _highlightIndex = index; + if (index >= 0) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + + if (glyph) { + if (_flags & GFLAG_4) { + Point pt; + int idx = getHighlightedIndex(_highlightIndex); + if (idx >= 0) + pt = getPosition(idx); + + glyph->highlightCurrent(pt); + } + + glyph->updateTooltip(); + } + } else if (_owner) { + _owner->removeText(); + } +} + +void CPetGlyphs::highlight(int index) { + if (index >= 0) { + setSelectedIndex(index); + changeHighlight(index); + makePetDirty(); + } +} + +void CPetGlyphs::highlight(const CPetGlyph *glyph) { + highlight(indexOf(glyph)); +} + +int CPetGlyphs::getHighlightedIndex(int index) const { + int idx = index - _firstVisibleIndex; + return (idx >= 0 && idx < _numVisibleGlyphs) ? idx : -1; +} + +int CPetGlyphs::getItemIndex(int index) const { + return _firstVisibleIndex + index; +} + +void CPetGlyphs::setSelectedIndex(int index) { + if (index >= 0 && index < (int)size() && getHighlightedIndex(index) == -1) { + if (_firstVisibleIndex <= index) + index -= _numVisibleGlyphs - 1; + + setFirstVisible(index); + } +} + +CPetGlyph *CPetGlyphs::getGlyph(int index) const { + for (const_iterator i = begin(); i != end(); ++i) { + if (index-- == 0) + return *i; + } + + return nullptr; +} + +CPetControl *CPetGlyphs::getPetControl() const { + return _owner ? _owner->getPetControl() : nullptr; +} + +void CPetGlyphs::setFirstVisible(int index) { + if (index != _firstVisibleIndex) { + _firstVisibleIndex = index; + + if ((_flags & GFLAG_8) && _highlightIndex != -1) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + + if (glyph) { + int idx = getHighlightedIndex(_highlightIndex); + if (idx != -1) { + Point tempPt = getPosition(idx); + glyph->glyphFocused(tempPt, true); + } + } + } + } +} + +void CPetGlyphs::scrollLeft() { + if (_firstVisibleIndex > 0) { + setFirstVisible(_firstVisibleIndex - 1); + if (_highlightIndex != -1) { + int index = getHighlightedIndex(_highlightIndex); + if (index == -1) + changeHighlight(_highlightIndex - 1); + } + + makePetDirty(); + } +} + +void CPetGlyphs::scrollRight() { + int count = size(); + int right = count - _numVisibleGlyphs; + + if (_firstVisibleIndex < right) { + setFirstVisible(_firstVisibleIndex + 1); + if (_highlightIndex != -1) { + int index = getHighlightedIndex(_highlightIndex); + if (index == -1) + changeHighlight(_highlightIndex + 1); + } + + makePetDirty(); + } +} + +void CPetGlyphs::makePetDirty() { + if (_owner && _owner->_petControl) + _owner->_petControl->makeDirty(); +} + +bool CPetGlyphs::MouseButtonDownMsg(const Point &pt) { + if (_scrollLeft.contains2(pt)) { + scrollLeft(); + return true; + } + + if (_scrollRight.contains2(pt)) { + scrollRight(); + return true; + } + + for (int idx = 0; idx < _numVisibleGlyphs; ++idx) { + Rect glyphRect = getRect(idx); + if (glyphRect.contains(pt)) { + int index = getItemIndex(idx); + CPetGlyph *glyph = getGlyph(index); + if (glyph) { + if (_highlightIndex == index) { + glyph->selectGlyph(glyphRect, pt); + glyph->updateTooltip(); + } else { + changeHighlight(index); + makePetDirty(); + } + + return true; + } + } + } + + if (_highlightIndex != -1) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + + if (glyph) { + if (glyph->MouseButtonDownMsg(pt)) + return true; + + if (!(_flags & GFLAG_2)) { + changeHighlight(-1); + makePetDirty(); + } + } + } + + return false; +} + +bool CPetGlyphs::MouseButtonUpMsg(const Point &pt) { + if (_highlightIndex >= 0) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + if (glyph) { + if (glyph->MouseButtonUpMsg(pt)) + return true; + } + } + + return false; +} + +bool CPetGlyphs::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!(_flags & GFLAG_1) && _highlightIndex >= 0) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + int index = getHighlightedIndex(_highlightIndex); + Rect glyphRect = getRect(index); + + if (glyphRect.contains(msg->_mousePos)) + return glyph->dragGlyph(glyphRect, msg); + else + return glyph->MouseDragStartMsg(msg); + } + + return false; +} + +bool CPetGlyphs::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + if (_dragGlyph) { + return _dragGlyph->MouseDragMoveMsg(msg); + } else { + return false; + } +} + +bool CPetGlyphs::MouseDragEndMsg(CMouseDragEndMsg *msg) { + if (_dragGlyph) { + return _dragGlyph->MouseDragEndMsg(msg); + } else { + return false; + } +} + +bool CPetGlyphs::KeyCharMsg(int key) { + if (_highlightIndex >= 0) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + + if (glyph && glyph->KeyCharMsg(key)) + return true; + } + + return false; +} + +bool CPetGlyphs::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + Common::KeyCode key = msg->_keyState.keycode; + + switch (key) { + case Common::KEYCODE_LEFT: + decSelection(); + return true; + + case Common::KEYCODE_RIGHT: + incSelection(); + return true; + + default: + break; + } + + if (_highlightIndex >= 0) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + if (glyph && glyph->VirtualKeyCharMsg(msg)) + return true; + } + + return false; +} + +bool CPetGlyphs::enterHighlighted() { + if (_highlightIndex >= 0) + return getGlyph(_highlightIndex)->enterHighlighted(); + else + return false; +} + +void CPetGlyphs::leaveHighlighted() { + if (_highlightIndex >= 0) + getGlyph(_highlightIndex)->leaveHighlighted(); +} + +void CPetGlyphs::startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg) { + if (glyph) { + _dragGlyph = glyph; + msg->_dragItem = getPetControl(); + } +} + +void CPetGlyphs::endDragging() { + _dragGlyph = nullptr; +} + +bool CPetGlyphs::highlighted14() { + if (_highlightIndex != -1) { + CPetGlyph *pet = getGlyph(_highlightIndex); + if (pet) { + pet->updateTooltip(); + return true; + } + } + + return false; +} + +int CPetGlyphs::indexOf(const CPetGlyph *glyph) const { + int index = 0; + for (const_iterator i = begin(); i != end(); ++i, ++index) { + if (*i == glyph) + return index; + } + + return -1; +} + +void CPetGlyphs::incSelection() { + if (_highlightIndex >= 0 && _highlightIndex < ((int)size() - 1)) { + if (getHighlightedIndex(_highlightIndex) >= (_numVisibleGlyphs - 1)) + scrollRight(); + + changeHighlight(_highlightIndex + 1); + makePetDirty(); + } +} + +void CPetGlyphs::decSelection() { + if (_highlightIndex > 0) { + if (getHighlightedIndex(_highlightIndex) == 0) + scrollLeft(); + + changeHighlight(_highlightIndex - 1); + makePetDirty(); + } +} + +CGameObject *CPetGlyphs::getObjectAt(const Point &pt) const { + for (int idx = 0; idx < _numVisibleGlyphs; ++idx) { + Rect glyphRect = getRect(idx); + if (glyphRect.contains(pt)) { + CPetGlyph *glyph = getGlyph(getItemIndex(idx)); + if (glyph) + return glyph->getObjectAt(); + } + } + + return nullptr; +} + +bool CPetGlyphs::isGlyphHighlighted(const CPetGlyph *glyph) const { + if (_highlightIndex == -1) + return false; + + return indexOf(glyph) == _highlightIndex; +} + +Point CPetGlyphs::getHighlightedGlyphPos() const { + if (_highlightIndex != -1) { + int idx = getHighlightedIndex(_highlightIndex); + if (idx >= 0) + return getPosition(idx); + } + + return Point(0, 0); +} + +bool CPetGlyphs::areItemsValid() const { + for (const_iterator i = begin(); i != end(); ++i) { + if (!(*i)->isValid()) + return false; + } + + return true; +} + +void CPetGlyphs::removeInvalid() { + if (!areItemsValid()) { + changeHighlight(-1); + + for (iterator i = begin(); i != end(); ) { + CPetGlyph *glyph = *i; + + if (!glyph->isValid()) { + i = erase(i); + delete glyph; + } else { + ++i; + } + } + + _firstVisibleIndex = CLIP(_firstVisibleIndex, 0, + (int)size() - _numVisibleGlyphs); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h new file mode 100644 index 0000000000..c07cc5ed9a --- /dev/null +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -0,0 +1,492 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_GLYPHS_H +#define TITANIC_PET_GLYPHS_H + +#include "common/keyboard.h" +#include "titanic/core/list.h" +#include "titanic/messages/mouse_messages.h" +#include "titanic/pet_control/pet_gfx_element.h" +#include "titanic/support/rect.h" + +namespace Titanic { + +#define TOTAL_GLYPHS 7 + +class CPetGlyphs; +class CPetSection; +class CPetText; + +enum GlyphActionMode { ACTION_REMOVE = 0, ACTION_REMOVED = 1, ACTION_CHANGE = 2 }; + +enum GlyphFlag { GFLAG_1 = 1, GFLAG_2 = 2, GFLAG_4 = 4, GFLAG_8 = 8, GFLAG_16 = 16 }; + +class CGlyphAction { +protected: + GlyphActionMode _mode; +public: + CGlyphAction() : _mode(ACTION_REMOVED) {} + CGlyphAction(GlyphActionMode mode) : _mode(mode) {} + + GlyphActionMode getMode() const { return _mode; } +}; + +class CPetGlyph : public ListItem { +protected: + /** + * Get the overall pet section owner + */ + CPetSection *getPetSection() const; +public: + CPetGfxElement _element; + CPetGlyphs *_owner; +public: + CPetGlyph() : ListItem(), _owner(nullptr) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Reset the glyph + */ + virtual bool reset() { return false; } + + /** + * Called when the PET area is entered + */ + virtual void enter() {} + + /** + * Called when the PET area is left + */ + virtual void leave() {} + + /** + * Draw the glyph at a specified position + */ + virtual void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager) {} + + /** + * Updates the tooltip being shown for the glyph + */ + virtual void updateTooltip(); + + /** + * Get the bounds for the glyph + */ + virtual Rect getBounds() const { return Rect(); } + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { return false; } + + /** + * Called when mouse drag starts + */ + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg) { return false; } + + /** + * Called during mouse drags + */ + virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) { return false; } + + /** + * Called when mouse drag ends + */ + virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { return false; } + + /** + * Handles mouse double-click messages + */ + virtual bool MouseDoubleClickMsg(const CMouseDoubleClickMsg *msg) { return false; } + + /** + * Handles keypresses + */ + virtual bool KeyCharMsg(int key) { return false; } + + /** + * Handles keypresses + */ + virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return false; } + + /** + * Unhighlight any currently highlighted element + */ + virtual void unhighlightCurrent() {} + + /** + * Highlight any currently highlighted element + */ + virtual void highlightCurrent(const Point &pt) {} + + /** + * Glyph has been shifted to be first visible one + */ + virtual void glyphFocused(const Point &topLeft, bool flag) {} + + /** + * Selects a glyph + */ + virtual void selectGlyph(const Point &topLeft, const Point &pt) {} + + /** + * Called when a glyph drag starts + */ + virtual bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) { return false; } + + /** + * Returns true if the glyph's bounds, shifted to a given position, + * will contain the specified point + */ + virtual bool contains(const Point &delta, const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text) {} + + /** + * Saves the data for the glyph + */ + virtual void saveGlyph(SimpleFile *file, int indent) {} + + virtual bool proc33(CPetGlyph *glyph) { return true; } + + /** + * Return whether the glyph is currently valid + */ + virtual bool isValid() const { return true; } + + /** + * Called on a highlighted item when PET area is entered + */ + virtual bool enterHighlighted() { return false; } + + /** + * Called on a highlighted item when PET area is left + */ + virtual void leaveHighlighted() {} + + /** + * Returns the object associated with the glyph + */ + virtual CGameObject *getObjectAt() { return nullptr; } + + /** + * Does a processing action on the glyph + */ + virtual bool doAction(CGlyphAction *action) { return true; } + + /** + * Translate the glyph's position + */ + void translate(const Point &pt) { _element.translate(pt.x, pt.y); } + + /** + * Translate the glyph's position back + */ + void translateBack(const Point &pt) { _element.translate(-pt.x, -pt.y); } + + /** + * Get the parent RealLife area + */ + CPetGlyphs *getOwner() { return _owner; } + + /** + * Get the PET control + */ + CPetControl *getPetControl() const; + + /** + * Sets new name and default bounds for glyph + */ + void setName(const CString &name, CPetControl *petControl); + + /** + * Returns true if the specified glyph is the currently highlighted one + */ + bool isHighlighted() const; +}; + +class CPetGlyphs : public List<CPetGlyph> { +private: + /** + * Get a position for the glyph + */ + Point getPosition(int index) const; + + /** + * Get a rect for the glyph + */ + Rect getRect(int index) const; + + /** + * Returns the on-screen index for the highlight to be shown at + */ + int getHighlightedIndex(int index) const; + + /** + * Returns the index of a glyph given the visible on-screen glyph number + */ + int getItemIndex(int index) const; + + /** + * Set the item index + */ + void setSelectedIndex(int index); + + /** + * Return a specified glyph + */ + CPetGlyph *getGlyph(int index) const; + + /** + * Scrolls the glyphs to the left + */ + void scrollLeft(); + + /** + * Scrolls the glyphs to the right + */ + void scrollRight(); + + /** + * Set the first visible glyph index + */ + void setFirstVisible(int index); + + /** + * Make the PET dirty + */ + void makePetDirty(); + + /** + * Returns true if all the glyphs are in a valid state + */ + bool areItemsValid() const; +protected: + int _firstVisibleIndex; + int _totalGlyphs; + int _numVisibleGlyphs; + int _highlightIndex; + int _field1C; + int _flags; + CPetGlyph *_dragGlyph; + CPetSection *_owner; + CPetGfxElement _selection; + CPetGfxElement _scrollLeft; + CPetGfxElement _scrollRight; +protected: + /** + * Change the currently selected glyph + */ + void changeHighlight(int index); +public: + CPetGlyphs(); + + /** + * Set the number of visible glyphs + */ + void setNumVisible(int total); + + /** + * Clears the glyph list + */ + void clear(); + + + /** + * The visual dimensions for the control and it's components + */ + virtual void setup(int numVisible, CPetSection *owner); + + /** + * Set up the control + */ + virtual void reset(); + + /** + * Called when PET area is entered + */ + virtual void enter(); + + /** + * Called when PET area is left + */ + virtual void leave(); + + void setFlags(int flags) { _flags = flags; } + + /** + * Draw the control + */ + void draw(CScreenManager *screenManager); + + /** + * Highlight a specific glyph by indexe + */ + void highlight(int index); + + /** + * Highlight a specific glyph + */ + void highlight(const CPetGlyph *glyph); + + /** + * Get the owning section for the glyphs + */ + CPetSection *getOwner() const { return _owner; } + + /** + * Get the PET control + */ + CPetControl *getPetControl() const; + + /** + * Mouse button down message + */ + bool MouseButtonDownMsg(const Point &pt); + + /** + * Mouse button up message + */ + bool MouseButtonUpMsg(const Point &pt); + + /** + * Mouse double click message + */ + bool MouseDoubleClickMsg(const Point &pt) { return true; } + + /** + * Mouse drag start messagge + */ + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + + /** + * Mouse drag move message + */ + bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + + /** + * Mouse drag end message + */ + bool MouseDragEndMsg(CMouseDragEndMsg *msg); + + /** + * Key character message + */ + bool KeyCharMsg(int key); + + /** + * Virtual key message + */ + bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + + /** + * When the PET section is entered, passes onto the highlighted + * glyph, if any + */ + bool enterHighlighted(); + + /** + * When the PET section is left, passes onto the highlighted + * glyph, if any + */ + void leaveHighlighted(); + + /** + * Called when a dragging operation starts + */ + void startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg); + + /** + * Called when a dragging operation ends + */ + void endDragging(); + + /** + * Reset the highlight + */ + void resetHighlight() { changeHighlight(-1); } + + bool highlighted14(); + + /** + * Returns the index of the specified glyph in the lsit + */ + int indexOf(const CPetGlyph *glyph) const; + + /** + * Resets the scrolling of the glyphs list back to the start + */ + void scrollToStart() { _firstVisibleIndex = 0; } + + /** + * Increment the currently selected index + */ + void incSelection(); + + /** + * Decrement the currently selected index + */ + void decSelection(); + + /** + * Returns the object associated the glyph under the specified position + */ + CGameObject *getObjectAt(const Point &pt) const; + + /** + * Returns true if the specified glyph is the currently highlighted one + */ + bool isGlyphHighlighted(const CPetGlyph *glyph) const; + + /** + * Get the top-left position of the currently highlighted glyph + */ + Point getHighlightedGlyphPos() const; + + /** + * Removes any glyphs from the list that no longer have any images + * associated with them + */ + void removeInvalid(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_GLYPHS_H */ diff --git a/engines/titanic/pet_control/pet_graphic.cpp b/engines/titanic/pet_control/pet_graphic.cpp new file mode 100644 index 0000000000..bc7d86142d --- /dev/null +++ b/engines/titanic/pet_control/pet_graphic.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetGraphic, CGameObject); + +void CPetGraphic::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPetGraphic::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_graphic.h b/engines/titanic/pet_control/pet_graphic.h new file mode 100644 index 0000000000..630c8446eb --- /dev/null +++ b/engines/titanic/pet_control/pet_graphic.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_GRAPHIC_H +#define TITANIC_PET_GRAPHIC_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPetGraphic : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_GRAPHIC_H */ diff --git a/engines/titanic/pet_control/pet_graphic2.cpp b/engines/titanic/pet_control/pet_graphic2.cpp new file mode 100644 index 0000000000..36c4d0f55a --- /dev/null +++ b/engines/titanic/pet_control/pet_graphic2.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_graphic2.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetGraphic2, CGameObject); + +void CPetGraphic2::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void CPetGraphic2::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_graphic2.h b/engines/titanic/pet_control/pet_graphic2.h new file mode 100644 index 0000000000..58852fc65e --- /dev/null +++ b/engines/titanic/pet_control/pet_graphic2.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_GRAPHIC2_H +#define TITANIC_PET_GRAPHIC2_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CPetGraphic2 : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_GRAPHIC2_H */ diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp new file mode 100644 index 0000000000..55176d8b0e --- /dev/null +++ b/engines/titanic/pet_control/pet_inventory.cpp @@ -0,0 +1,255 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_inventory.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/carry/carry.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CPetInventory::CPetInventory() : CPetSection(), + _movie(nullptr), _field290(false), _field294(0), _field298(0) { + for (int idx = 0; idx < TOTAL_ITEMS; ++idx) { + _itemBackgrounds[idx] = _itemGlyphs[idx] = nullptr; + } +} + +bool CPetInventory::setup(CPetControl *petControl) { + return setPetControl(petControl) && reset(); +} + +bool CPetInventory::reset() { + _items.reset(); + _text.setup(); + _text.setColor(getColor(0)); + _text.setLineColor(0, getColor(0)); + + return true; +} + +void CPetInventory::draw(CScreenManager *screenManager) { + _petControl->drawSquares(screenManager, 7); + _items.draw(screenManager); + _text.draw(screenManager); +} + +Rect CPetInventory::getBounds() const { + return _movie ? _movie->getBounds() : Rect(); +} + +void CPetInventory::changed(int changeType) { + switch (changeType) { + case 0: + case 2: + itemsChanged(); + break; + case 1: + removeInvalid(); + break; + default: + break; + } +} + +bool CPetInventory::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return _items.MouseButtonDownMsg(msg->_mousePos); +} + +bool CPetInventory::MouseDragStartMsg(CMouseDragStartMsg *msg) { + bool result = _items.MouseDragStartMsg(msg); + if (result) + _petControl->makeDirty(); + return result; +} + +bool CPetInventory::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + return _items.MouseButtonUpMsg(msg->_mousePos); +} + +bool CPetInventory::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + return _items.MouseDoubleClickMsg(msg->_mousePos); +} + +bool CPetInventory::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + return _items.VirtualKeyCharMsg(msg); +} + +CGameObject *CPetInventory::dragEnd(const Point &pt) const { + return _items.getObjectAt(pt); +} + +bool CPetInventory::isValid(CPetControl *petControl) { + setPetControl(petControl); + return true; +} + +void CPetInventory::load(SimpleFile *file, int param) { + _field298 = file->readNumber(); +} + +void CPetInventory::postLoad() { + reset(); + _field290 = 1; + itemsChanged(); + _field290 = 0; +} + +void CPetInventory::save(SimpleFile *file, int indent) { + file->writeNumberLine(_field298, indent); +} + +void CPetInventory::enter(PetArea oldArea) { + _items.enter(); +} + +void CPetInventory::leave() { + _items.leave(); +} + +CGameObject *CPetInventory::getBackground(int index) const { + return (index >= 0 && index < 46) ? _itemBackgrounds[index] : nullptr; +} + +bool CPetInventory::setPetControl(CPetControl *petControl) { + if (!petControl) + return false; + + _petControl = petControl; + _items.setup(7, this); + _items.setFlags(28); + + Rect tempRect(0, 0, 52, 52); + for (uint idx = 0; idx < TOTAL_ITEMS; ++idx) { + if (!g_vm->_itemNames[idx].empty()) { + CString name = "3Pet" + g_vm->_itemNames[idx]; + _itemBackgrounds[idx] = petControl->getHiddenObject(name); + } + + if (!g_vm->_itemObjects[idx].empty()) { + _itemGlyphs[idx] = petControl->getHiddenObject(g_vm->_itemObjects[idx]); + } + } + + tempRect = Rect(0, 0, 580, 15); + tempRect.translate(32, 445); + _text.setBounds(tempRect); + _text.setHasBorder(false); + + return true; +} + +void CPetInventory::change(CGameObject *item) { + if (item) { + CInventoryGlyphAction action(item, ACTION_CHANGE); + _items.doAction(&action); + } +} + +void CPetInventory::itemRemoved(CGameObject *item) { + if (item) { + CInventoryGlyphAction action(item, ACTION_REMOVED); + _items.doAction(&action); + } +} + +void CPetInventory::itemsChanged() { + _items.clear(); + + CGameObject *item = _petControl->getFirstObject(); + while (item) { + CPetInventoryGlyph *glyph = new CPetInventoryGlyph(); + glyph->setup(_petControl, &_items); + glyph->setItem(item, _field290); + + _items.push_back(glyph); + item = _petControl->getNextObject(item); + } +} + +void CPetInventory::highlightItem(CGameObject *item) { + int itemIndex = getItemIndex(item); + _items.highlight(itemIndex); +} + +int CPetInventory::getItemIndex(CGameObject *item) const { + int index = 0; + for (CGameObject *obj = _petControl->getFirstObject(); obj && obj != item; + ++index, obj = _petControl->getNextObject(obj)) { + } + + return index; +} + +CGameObject *CPetInventory::getImage(int index) { + if (index >= 0 && index < 46) { + int bits = 0; + switch (index) { + case 20: + bits = 4; + break; + case 21: + bits = 8; + break; + case 22: + bits = 1; + break; + case 23: + bits = 2; + break; + case 36: + bits = 32; + break; + case 39: + bits = 16; + break; + default: + break; + } + + if (!(bits & _field298)) { + _field298 = bits | _field298; + return _itemGlyphs[index]; + } + } + + return nullptr; +} + +void CPetInventory::playMovie(CGameObject *movie, int flag) { + if (_movie) + _movie->stopMovie(); + _movie = movie; + + if (_movie) { + if (flag) + _movie->playMovie(0, 14, 1); + else + _movie->playMovie(0); + } +} + +void CPetInventory::removeInvalid() { + _items.removeInvalid(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h new file mode 100644 index 0000000000..17649546ce --- /dev/null +++ b/engines/titanic/pet_control/pet_inventory.h @@ -0,0 +1,174 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_INVENTORY_H +#define TITANIC_PET_INVENTORY_H + +#include "titanic/support/simple_file.h" +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_inventory_glyphs.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +/** + * Handles displaying the player's inventory in the PET + */ +class CPetInventory : public CPetSection { +private: + CPetText _text; + CPetInventoryGlyphs _items; + CGameObject *_itemBackgrounds[46]; + CGameObject *_itemGlyphs[46]; + CGameObject *_movie; + bool _field290; + int _field294; + int _field298; +private: + /** + * Handles initial setup + */ + bool setPetControl(CPetControl *petControl); + + /** + * Get the index of an item added to the PET + */ + int getItemIndex(CGameObject *item) const; + + /** + * Remove any invalid inventory glyphs + */ + void removeInvalid(); +public: + CPetInventory(); + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Sets up the section + */ + virtual bool reset(); + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Get the bounds for the section + */ + virtual Rect getBounds() const; + + /** + * Called when a general change occurs + */ + virtual void changed(int changeType); + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg); + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); + virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + + /** + * Returns item a drag-drop operation has dropped on, if any + */ + virtual CGameObject *dragEnd(const Point &pt) const; + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param); + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea); + + /** + * Called when a section is being left, to switch to another area + */ + virtual void leave(); + + /** + * Get a reference to the tooltip text associated with the section + */ + virtual CPetText *getText() { return &_text; } + + /** + * Special retrieval of glyph background image + */ + virtual CGameObject *getBackground(int index) const; + + /** + * + */ + void change(CGameObject *item); + + /** + * Called when an item has been removed from the PET + */ + void itemRemoved(CGameObject *item); + + /** + * Called when the items under the PET have changed + */ + void itemsChanged(); + + /** + * Called when the inventory can't be shown after adding an item + */ + void highlightItem(CGameObject *item); + + CGameObject *getImage(int index); + + /** + * Play the animated movie for an object + */ + void playMovie(CGameObject *movie, int flag); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_INVENTORY_H */ diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp new file mode 100644 index 0000000000..ae306649a2 --- /dev/null +++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp @@ -0,0 +1,342 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_inventory_glyphs.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_inventory.h" +#include "titanic/messages/pet_messages.h" +#include "titanic/titanic.h" + +namespace Titanic { + +const uint ITEM_MODES[40] = { + 0, 2, 11, 10, 12, 13, 9, 40, 7, 6, + 4, 5, 8, 15, 19, 24, 25, 26, 30, 20, + 21, 22, 23, 36, 39, 39, 31, 31, 32, 32, + 33, 34, 35, 38, 41, 42, 43, 44, 45, 37 +}; + +void CPetInventoryGlyph::enter() { + startBackgroundMovie(); +} + +void CPetInventoryGlyph::leave() { + stopMovie(); +} + +void CPetInventoryGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) { + if (!_field34) + return; + + if (_image) { + if (_image->hasActiveMovie()) { + if (isHighlighted_) + _image->draw(screenManager); + else + _image->draw(screenManager, pt); + return; + } + + _image = nullptr; + if (_background && isHighlighted_) { + _background->setPosition(pt); + startBackgroundMovie(); + } + } + + if (_background) { + if (isHighlighted_) + _background->draw(screenManager); + else + _background->draw(screenManager, pt); + } else if (_image) { + _image->draw(screenManager, pt, Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + } +} + + +void CPetInventoryGlyph::unhighlightCurrent() { + if (_image) { + _image->setPosition(Point(0, 0)); + stopMovie(); + } else if (_background) { + _background->setPosition(Point(0, 0)); + _background->loadFrame(0); + stopMovie(); + } +} + +void CPetInventoryGlyph::highlightCurrent(const Point &pt) { + reposition(pt); + if (_item) { + CPETObjectSelectedMsg selectedMsg; + selectedMsg.execute(_item); + } +} + +void CPetInventoryGlyph::glyphFocused(const Point &topLeft, bool flag) { + if (_background && flag) + _background->setPosition(topLeft); +} + +bool CPetInventoryGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) { + if (!_item) + return false; + + if (_background) { + _field34 = 0; + stopMovie(); + } + + CPetControl *petControl = getPetControl(); + if (!petControl) + return false; + + CGameObject *carryParcel = petControl->getHiddenObject("CarryParcel"); + + if (petControl->isSuccUBusActive() && carryParcel) { + petControl->removeFromInventory(_item, carryParcel, false, true); + petControl->removeFromInventory(_item, false, false); + + carryParcel->setPosition(Point(msg->_mousePos.x - carryParcel->getBounds().width() / 2, + msg->_mousePos.y - carryParcel->getBounds().height() / 2)); + _item->setPosition(Point(SCREEN_WIDTH, SCREEN_HEIGHT)); + } else { + petControl->removeFromInventory(_item, false, true); + + _item->setPosition(Point(msg->_mousePos.x - carryParcel->getBounds().width() / 2, + msg->_mousePos.y - carryParcel->getBounds().height() / 2)); + _item->setVisible(true); + } + + msg->_handled = true; + if (msg->execute(carryParcel)) { + _item = nullptr; + _background = nullptr; + _field34 = 0; + petControl->setAreaChangeType(1); + return true; + } else { + petControl->addToInventory(carryParcel); + return false; + } +} + +void CPetInventoryGlyph::getTooltip(CPetText *text) { + if (text) { + text->setText(""); + + if (_field34 && _item) { + int itemIndex = populateItem(_item, 0); + if (itemIndex >= 14 && itemIndex <= 18) { + CPETObjectStateMsg stateMsg(0); + stateMsg.execute(_item); + + text->setText(CString::format("%s %s", + stateMsg._value ? "A hot " : "A cold ", + g_vm->_itemDescriptions[itemIndex].c_str() + )); + + } else { + text->setText(g_vm->_itemDescriptions[itemIndex]); + } + } + } +} + +bool CPetInventoryGlyph::doAction(CGlyphAction *action) { + CInventoryGlyphAction *invAction = static_cast<CInventoryGlyphAction *>(action); + CPetInventoryGlyphs *owner = static_cast<CPetInventoryGlyphs *>(_owner); + if (!invAction) + return false; + + switch (invAction->getMode()) { + case ACTION_REMOVED: + if (invAction->_item == _item) { + _item = nullptr; + _background = nullptr; + _field34 = 0; + } + break; + + case ACTION_REMOVE: + if (_item == invAction->_item && _owner) { + int v = populateItem(_item, 0); + _background = owner->getBackground(v); + + if (isHighlighted()) { + Point glyphPos = _owner->getHighlightedGlyphPos(); + reposition(glyphPos); + updateTooltip(); + } + } + break; + + default: + break; + } + + return true; +} + +void CPetInventoryGlyph::setItem(CGameObject *item, int val) { + _item = item; + + if (_owner && item) { + int v1 = populateItem(item, val); + _background = static_cast<CPetInventoryGlyphs *>(_owner)->getBackground(v1); + _image = static_cast<CPetInventory *>(getPetSection())->getImage(v1); + } +} + +int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { + // Scan the master item names list + CString itemName = item->getName(); + int itemIndex = -1; + for (int idx = 0; idx < 40 && itemIndex == -1; ++idx) { + if (itemName == g_vm->_itemIds[idx]) + itemIndex = idx; + } + if (itemIndex == -1) + return -1; + + switch (ITEM_MODES[itemIndex]) { + case 0: + switch (subMode(item, val)) { + case 0: + case 1: + return 0; + case 2: + case 3: + return 1; + default: + return 0; + } + + case 2: + switch (subMode(item, val)) { + case 0: + return 2; + default: + return 3; + } + break; + + case 15: + switch (subMode(item, val)) { + case 0: + case 1: + return 14; + case 2: + return 16; + case 3: + return 15; + case 4: + return 17; + case 5: + return 18; + default: + return 15; + } + break; + + case 26: + switch (subMode(item, val)) { + case 0: + return 26; + case 1: + return 29; + case 2: + return 28; + case 3: + return 27; + default: + return 26; + } + break; + + default: + break; + } + + return ITEM_MODES[itemIndex]; +} + +int CPetInventoryGlyph::subMode(CGameObject *item, int val) { + int frameNum = item->getFrameNumber(); + int movieFrame = item->getMovieFrame(); + + if (val && frameNum != -1 && frameNum != movieFrame) + item->loadFrame(frameNum); + + return frameNum; +} + +void CPetInventoryGlyph::startBackgroundMovie() { + if (_owner) { + CPetInventory *section = static_cast<CPetInventory *>(_owner->getOwner()); + if (section) + section->playMovie(_background, 1); + } +} + +void CPetInventoryGlyph::startForegroundMovie() { + if (_owner) { + CPetInventory *section = static_cast<CPetInventory *>(_owner->getOwner()); + if (section) + section->playMovie(_image, 1); + } +} + +void CPetInventoryGlyph::stopMovie() { + if (_owner) { + CPetInventory *section = static_cast<CPetInventory *>(_owner->getOwner()); + if (section) + section->playMovie(nullptr, 1); + } +} + +void CPetInventoryGlyph::reposition(const Point &pt) { + if (_image) { + _image->setPosition(pt); + startForegroundMovie(); + } else if (_background) { + _background->setPosition(pt); + startBackgroundMovie(); + } +} + +/*------------------------------------------------------------------------*/ + +bool CPetInventoryGlyphs::doAction(CInventoryGlyphAction *action) { + for (iterator i = begin(); i != end(); ++i) { + (*i)->doAction(action); + } + + return true; +} + +CGameObject *CPetInventoryGlyphs::getBackground(int index) { + return _owner ? _owner->getBackground(index) : nullptr; +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h new file mode 100644 index 0000000000..716c9d1ad1 --- /dev/null +++ b/engines/titanic/pet_control/pet_inventory_glyphs.h @@ -0,0 +1,153 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_INVENTORY_GLYPHS_H +#define TITANIC_PET_INVENTORY_GLYPHS_H + +#include "titanic/carry/carry.h" +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/support/screen_manager.h" + +namespace Titanic { + +class CPetInventoryGlyph : public CPetGlyph { +private: + /** + * Populate the details for an item + */ + int populateItem(CGameObject *item, int val); + + int subMode(CGameObject *item, int val); + + /** + * Start any movie for the background + */ + void startBackgroundMovie(); + + /** + * Start any movie for the foreground item + */ + void startForegroundMovie(); + + /** + * Stop any previously started foreground or background movie + */ + void stopMovie(); + + /** + * Reposition the inventory item + */ + void reposition(const Point &pt); +public: + CGameObject *_item; + int _field34; + CGameObject *_background; + CGameObject *_image; +public: + CPetInventoryGlyph() : _item(nullptr), _field34(1), + _background(nullptr), _image(nullptr) {} + CPetInventoryGlyph(CCarry *item, int val) : _item(item), + _field34(val), _background(nullptr), _image(nullptr) {} + + /** + * Called when the PET area is entered + */ + virtual void enter(); + + /** + * Called when the PET area is left + */ + virtual void leave(); + + /** + * Draw the glyph at a specified position + */ + virtual void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted); + + /** + * Unhighlight any currently highlighted element + */ + virtual void unhighlightCurrent(); + + /** + * Highlight any currently highlighted element + */ + virtual void highlightCurrent(const Point &pt); + + /** + * Glyph has been shifted to be first visible one + */ + virtual void glyphFocused(const Point &topLeft, bool flag); + + /** + * Called when a glyph drag starts + */ + virtual bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); + + /** + * Return whether the glyph is currently valid + */ + virtual bool isValid() const { return _item && _background; } + + /** + * Returns the object associated with the glyph + */ + virtual CGameObject *getObjectAt() { return _item; } + + /** + * Does a processing action on the glyph + */ + virtual bool doAction(CGlyphAction *action); + + /** + * Set the inventory item + */ + void setItem(CGameObject *item, int val); +}; + +class CInventoryGlyphAction : public CGlyphAction { +public: + CGameObject *_item; +public: + CInventoryGlyphAction(CGameObject *item, GlyphActionMode mode) : + CGlyphAction(mode), _item(item) {} +}; + +class CPetInventoryGlyphs : public CPetGlyphs { + friend class CPetInventoryGlyph; +private: + CGameObject *getBackground(int index); +public: + /** + * Do an action on the glyphs + */ + bool doAction(CInventoryGlyphAction *item); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_INVENTORY_GLYPHS_H */ diff --git a/engines/titanic/pet_control/pet_leaf.cpp b/engines/titanic/pet_control/pet_leaf.cpp new file mode 100644 index 0000000000..718ffe5e6e --- /dev/null +++ b/engines/titanic/pet_control/pet_leaf.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_leaf.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(PETLeaf, CGameObject); + +void PETLeaf::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CGameObject::save(file, indent); +} + +void PETLeaf::load(SimpleFile *file) { + file->readNumber(); + CGameObject::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_leaf.h b/engines/titanic/pet_control/pet_leaf.h new file mode 100644 index 0000000000..0c21352e39 --- /dev/null +++ b/engines/titanic/pet_control/pet_leaf.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_LEAF_H +#define TITANIC_PET_LEAF_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class PETLeaf : public CGameObject { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_LEAF_H */ diff --git a/engines/titanic/pet_control/pet_load.cpp b/engines/titanic/pet_control/pet_load.cpp new file mode 100644 index 0000000000..04eec54f25 --- /dev/null +++ b/engines/titanic/pet_control/pet_load.cpp @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_load.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/core/project_item.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +bool CPetLoad::reset() { + CPetLoadSave::reset(); + + CPetControl *pet = getPetControl(); + if (pet) { + setName("PetLoad", pet); + _btnLoadSave.reset("PetLoadOut", pet, MODE_UNSELECTED); + _btnLoadSave.reset("PetLoadIn", pet, MODE_SELECTED); + } + + return true; +} + +bool CPetLoad::MouseButtonUpMsg(const Point &pt) { + if (_btnLoadSave.MouseButtonUpMsg(pt)) { + execute(); + return true; + } else { + return false; + } +} + +void CPetLoad::getTooltip(CPetText *text) { + text->setText("Load the game."); +} + +void CPetLoad::execute() { + CPetControl *pet = getPetControl(); + + if (_savegameSlotNum >= 0 && _slotInUse[_savegameSlotNum]) { + CMainGameWindow *window = g_vm->_window; + + // WORKAROUND: Schedule the savegame to be loaded after frame rendering ends + window->loadGame(_savegameSlotNum); + } else if (pet) { + pet->displayMessage("You must select a game to load first."); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_load.h b/engines/titanic/pet_control/pet_load.h new file mode 100644 index 0000000000..421531974d --- /dev/null +++ b/engines/titanic/pet_control/pet_load.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_LOAD_H +#define TITANIC_PET_LOAD_H + +#include "titanic/pet_control/pet_load_save.h" + +namespace Titanic { + +class CPetLoad : public CPetLoadSave { +public: + /** + * Reset the glyph + */ + virtual bool reset(); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Highlight any currently highlighted element + */ + virtual void highlightCurrent(const Point &pt) { resetSlots(); } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); + + /** + * Highlights a save slot + */ + virtual void highlightSave(int index) {} + + /** + * Unhighlight a save slot + */ + virtual void unhighlightSave(int index) {} + + /** + * Executes the loading or saving + */ + virtual void execute(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_LOAD_H */ diff --git a/engines/titanic/pet_control/pet_load_save.cpp b/engines/titanic/pet_control/pet_load_save.cpp new file mode 100644 index 0000000000..aebe43551e --- /dev/null +++ b/engines/titanic/pet_control/pet_load_save.cpp @@ -0,0 +1,191 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_load_save.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/core/project_item.h" +#include "titanic/titanic.h" + +namespace Titanic { + +int CPetLoadSave::_savegameSlotNum; + +bool CPetLoadSave::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetGlyph::setup(petControl, owner); + _savegameSlotNum = -1; + + for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) { + Rect slotRect = getSlotBounds(idx); + _slotNames[idx].setBounds(slotRect); + _slotNames[idx].resize(3); + _slotNames[idx].setMaxCharsPerLine(22); + _slotNames[idx].setHasBorder(false); + _slotNames[idx].setup(); + } + + Rect r1(0, 0, 68, 52); + r1.moveTo(496, 388); + _btnLoadSave.setBounds(r1); + + Rect r2(0, 0, 168, 78); + r2.moveTo(309, 377); + _gutter.setBounds(r2); + return true; +} + +bool CPetLoadSave::reset() { + highlightChange(); + resetSlots(); + + CPetControl *pet = getPetControl(); + if (pet) { + _gutter.reset("PetSaveGutter", pet, MODE_UNSELECTED); + } + + return true; +} + +void CPetLoadSave::draw2(CScreenManager *screenManager) { + _gutter.draw(screenManager); + + for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) + _slotNames[idx].draw(screenManager); + + _btnLoadSave.draw(screenManager); +} + +bool CPetLoadSave::MouseButtonDownMsg(const Point &pt) { + if (_btnLoadSave.MouseButtonDownMsg(pt)) + return true; + + checkSlotsHighlight(pt); + return false; +} + +bool CPetLoadSave::KeyCharMsg(int key) { + switch (key) { + case Common::KEYCODE_TAB: + case Common::KEYCODE_DOWN: + case Common::KEYCODE_KP2: + if (_savegameSlotNum != -1) { + highlightSlot((_savegameSlotNum + 1) % 5); + getPetControl()->makeDirty(); + } + return true; + + case Common::KEYCODE_UP: + case Common::KEYCODE_KP8: + if (_savegameSlotNum != -1) { + int slotNum = --_savegameSlotNum; + highlightSlot((slotNum == -1) ? SAVEGAME_SLOTS_COUNT - 1 : slotNum); + getPetControl()->makeDirty(); + } + return true; + + case Common::KEYCODE_RETURN: + case Common::KEYCODE_KP_ENTER: + execute(); + return true; + + default: + return false; + } +} + +Rect CPetLoadSave::getSlotBounds(int index) { + return Rect(323, 376 + index * 16, 473, 392 + index * 16); +} + +void CPetLoadSave::resetSlots() { + for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) { + _slotNames[idx].setText("Empty"); + _slotInUse[idx] = false; + + // Try and open up the savegame for access + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading( + g_vm->generateSaveName(idx)); + + if (in) { + // Read in the savegame header data + CompressedFile file; + file.open(in); + + TitanicSavegameHeader header; + if (CProjectItem::readSavegameHeader(&file, header)) { + _slotInUse[idx] = true; + _slotNames[idx].setText(header._saveName); + } + + if (header._thumbnail) { + header._thumbnail->free(); + delete header._thumbnail; + } + + file.close(); + } + } + + highlightSlot(_savegameSlotNum); +} + +void CPetLoadSave::highlightSlot(int index) { + unhighlightSave(_savegameSlotNum); + _savegameSlotNum = index; + highlightChange(); + highlightSave(_savegameSlotNum); +} + +void CPetLoadSave::highlightChange() { + CPetSection *section = getPetSection(); + + uint col = section ? section->getColor(3) : 0; + for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) + _slotNames[idx].setColor(col); + + if (_savegameSlotNum != -1) { + col = section ? section->getColor(4) : 0; + _slotNames[_savegameSlotNum].setLineColor(0, col); + } +} + +bool CPetLoadSave::checkSlotsHighlight(const Point &pt) { + for (int idx = 0; idx < SAVEGAME_SLOTS_COUNT; ++idx) { + if (isSlotHighlighted(idx, pt)) { + highlightSlot(idx); + return true; + } + } + + return false; +} + +bool CPetLoadSave::isSlotHighlighted(int index, const Point &pt) { + Rect r = getSlotBounds(index); + if (r.contains(pt)) { + highlightSlot(index); + return true; + } else { + return false; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_load_save.h b/engines/titanic/pet_control/pet_load_save.h new file mode 100644 index 0000000000..dd1c907ef1 --- /dev/null +++ b/engines/titanic/pet_control/pet_load_save.h @@ -0,0 +1,119 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_LOAD_SAVE_H +#define TITANIC_PET_LOAD_SAVE_H + +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +#define SAVEGAME_SLOTS_COUNT 5 + +class CPetLoadSave : public CPetGlyph { +private: + /** + * Get the rect area for a given savegame name will be displayed in + */ + Rect getSlotBounds(int index); + + /** + * Highlight one of the slots + */ + void highlightSlot(int index); + + /** + * Called when savegame slot highlight changes or the view is reset + */ + void highlightChange(); + + /** + * Check for whether a slot is under the passed point + */ + bool checkSlotsHighlight(const Point &pt); + + /** + * Checks if a point is within a given saveame slot + */ + bool isSlotHighlighted(int index, const Point &pt); +protected: + CPetText _slotNames[SAVEGAME_SLOTS_COUNT]; + bool _slotInUse[SAVEGAME_SLOTS_COUNT]; + CPetGfxElement _btnLoadSave; + CPetGfxElement _gutter; + static int _savegameSlotNum; +protected: + /** + * Reset the slot names list + */ + void resetSlots(); +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Reset the glyph + */ + virtual bool reset(); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles keypresses when the glyph is focused + */ + virtual bool KeyCharMsg(int key); + + /** + * Resets highlighting on the save slots + */ + virtual void resetSaves() { resetSlots(); } + + /** + * Highlights a save slot + */ + virtual void highlightSave(int index) = 0; + + /** + * Unhighlight a save slot + */ + virtual void unhighlightSave(int index) = 0; + + /** + * Executes the loading or saving + */ + virtual void execute() = 0; +}; + +} // End of namespace Titanic + +#endif diff --git a/engines/titanic/pet_control/pet_message.cpp b/engines/titanic/pet_control/pet_message.cpp new file mode 100644 index 0000000000..783c9019e2 --- /dev/null +++ b/engines/titanic/pet_control/pet_message.cpp @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_message.h" + +namespace Titanic { + +CPetMessage::CPetMessage() { + Rect rect1(0, 0, 580, 70); + rect1.translate(32, 368); + _message.setBounds(rect1); + _message.resize(50); + _message.setHasBorder(false); + + Rect rect2(0, 0, 580, 15); + rect2.translate(32, 445); + _tooltip.setBounds(rect2); + _tooltip.setHasBorder(false); +} + +bool CPetMessage::setup(CPetControl *petControl) { + if (petControl && setupControl(petControl)) + return reset(); + return false; +} + +void CPetMessage::draw(CScreenManager *screenManager) { + _message.draw(screenManager); + _tooltip.draw(screenManager); +} + +bool CPetMessage::setupControl(CPetControl *petControl) { + if (petControl) + _petControl = petControl; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_message.h b/engines/titanic/pet_control/pet_message.h new file mode 100644 index 0000000000..499f274c54 --- /dev/null +++ b/engines/titanic/pet_control/pet_message.h @@ -0,0 +1,96 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_MESSAGE_H +#define TITANIC_PET_MESSAGE_H + +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +class CPetMessage : public CPetSection { +private: + CPetText _message; + CPetText _tooltip; +private: + /** + * Setup the control + */ + bool setupControl(CPetControl *petControl); +public: + CPetMessage(); + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Reset the section + */ + virtual bool reset() { return true; } + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) { return false; } + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) { return false; } + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl) { + return setupControl(petControl); + } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param) {} + + /** + * Called after a game has been loaded + */ + virtual void postLoad() { reset(); } + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) {} + + /** + * Get a reference to the tooltip text associated with the section + */ + virtual CPetText *getText() { return &_tooltip; } + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_MESSAGE_H */ diff --git a/engines/titanic/pet_control/pet_mode_off.cpp b/engines/titanic/pet_control/pet_mode_off.cpp new file mode 100644 index 0000000000..119c15a65c --- /dev/null +++ b/engines/titanic/pet_control/pet_mode_off.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_mode_off.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetModeOff, CToggleSwitch); + +CPetModeOff::CPetModeOff() : CToggleSwitch() { +} + +void CPetModeOff::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CPetModeOff::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_mode_off.h b/engines/titanic/pet_control/pet_mode_off.h new file mode 100644 index 0000000000..9162270953 --- /dev/null +++ b/engines/titanic/pet_control/pet_mode_off.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_MODE_OFF_H +#define TITANIC_PET_MODE_OFF_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CPetModeOff : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CPetModeOff(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_MODE_OFF_H */ diff --git a/engines/titanic/pet_control/pet_mode_on.cpp b/engines/titanic/pet_control/pet_mode_on.cpp new file mode 100644 index 0000000000..2b61461a24 --- /dev/null +++ b/engines/titanic/pet_control/pet_mode_on.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_mode_on.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetModeOn, CToggleSwitch); + +CPetModeOn::CPetModeOn() : CToggleSwitch() { +} + +void CPetModeOn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CPetModeOn::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_mode_on.h b/engines/titanic/pet_control/pet_mode_on.h new file mode 100644 index 0000000000..f77fd1f447 --- /dev/null +++ b/engines/titanic/pet_control/pet_mode_on.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_MODE_ON_H +#define TITANIC_PET_MODE_ON_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CPetModeOn : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CPetModeOn(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_MODE_ON_H */ diff --git a/engines/titanic/pet_control/pet_mode_panel.cpp b/engines/titanic/pet_control/pet_mode_panel.cpp new file mode 100644 index 0000000000..8579c31cea --- /dev/null +++ b/engines/titanic/pet_control/pet_mode_panel.cpp @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_mode_panel.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetModePanel, CToggleSwitch); + +CPetModePanel::CPetModePanel() : CToggleSwitch() { +} + +void CPetModePanel::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CToggleSwitch::save(file, indent); +} + +void CPetModePanel::load(SimpleFile *file) { + file->readNumber(); + CToggleSwitch::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_mode_panel.h b/engines/titanic/pet_control/pet_mode_panel.h new file mode 100644 index 0000000000..f37c543b98 --- /dev/null +++ b/engines/titanic/pet_control/pet_mode_panel.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_MODE_PANEL_H +#define TITANIC_PET_MODE_PANEL_H + +#include "titanic/gfx/toggle_switch.h" + +namespace Titanic { + +class CPetModePanel : public CToggleSwitch { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CPetModePanel(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_MODE_PANEL_H */ diff --git a/engines/titanic/pet_control/pet_pannel1.cpp b/engines/titanic/pet_control/pet_pannel1.cpp new file mode 100644 index 0000000000..7a757bfe57 --- /dev/null +++ b/engines/titanic/pet_control/pet_pannel1.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_pannel1.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetPannel1, CPetGraphic); + +void CPetPannel1::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CPetPannel1::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_pannel1.h b/engines/titanic/pet_control/pet_pannel1.h new file mode 100644 index 0000000000..f39314fed9 --- /dev/null +++ b/engines/titanic/pet_control/pet_pannel1.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_PANNEL1_H +#define TITANIC_PET_PANNEL1_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CPetPannel1 : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_PANNEL1_H */ diff --git a/engines/titanic/pet_control/pet_pannel2.cpp b/engines/titanic/pet_control/pet_pannel2.cpp new file mode 100644 index 0000000000..096a39afbf --- /dev/null +++ b/engines/titanic/pet_control/pet_pannel2.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_pannel2.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetPannel2, CPetGraphic); + +void CPetPannel2::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CPetPannel2::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_pannel2.h b/engines/titanic/pet_control/pet_pannel2.h new file mode 100644 index 0000000000..f820847035 --- /dev/null +++ b/engines/titanic/pet_control/pet_pannel2.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_PANNEL2_H +#define TITANIC_PET_PANNEL2_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CPetPannel2 : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_PANNEL2_H */ diff --git a/engines/titanic/pet_control/pet_pannel3.cpp b/engines/titanic/pet_control/pet_pannel3.cpp new file mode 100644 index 0000000000..0d095a62c5 --- /dev/null +++ b/engines/titanic/pet_control/pet_pannel3.cpp @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_pannel3.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CPetPannel3, CPetGraphic); + +void CPetPannel3::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CPetGraphic::save(file, indent); +} + +void CPetPannel3::load(SimpleFile *file) { + file->readNumber(); + CPetGraphic::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_pannel3.h b/engines/titanic/pet_control/pet_pannel3.h new file mode 100644 index 0000000000..dd0d2f9fa2 --- /dev/null +++ b/engines/titanic/pet_control/pet_pannel3.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_PANNEL3_H +#define TITANIC_PET_PANNEL3_H + +#include "titanic/pet_control/pet_graphic.h" + +namespace Titanic { + +class CPetPannel3 : public CPetGraphic { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_PANNEL3_H */ diff --git a/engines/titanic/pet_control/pet_quit.cpp b/engines/titanic/pet_control/pet_quit.cpp new file mode 100644 index 0000000000..218ed89812 --- /dev/null +++ b/engines/titanic/pet_control/pet_quit.cpp @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_quit.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_real_life.h" +#include "titanic/support/rect.h" +#include "titanic/game_manager.h" + +namespace Titanic { + +bool CPetQuit::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetGlyph::setup(petControl, owner); + + Rect tempRect(0, 0, 280, 16); + tempRect.moveTo(322, 407); + _text.setBounds(tempRect); + _text.resize(3); + _text.setHasBorder(false); + _text.setup(); + + Rect btnRect(0, 0, 68, 52); + btnRect.moveTo(496, 388); + _btnYes.setBounds(btnRect); + + return true; +} + +bool CPetQuit::reset() { + CPetControl *pet = getPetControl(); + if (!pet) + return false; + + setName("PetExit", pet); + + uint col = getPetSection()->getColor(0); + _text.setText("Are you sure you want to quit?"); + _text.setLineColor(0, col); + + _btnYes.reset("PetQuitOut", pet, MODE_UNSELECTED); + _btnYes.reset("PetQuitIn", pet, MODE_SELECTED); + + return true; +} + +void CPetQuit::draw2(CScreenManager *screenManager) { + _text.draw(screenManager); + _btnYes.draw(screenManager); +} + +bool CPetQuit::MouseButtonDownMsg(const Point &pt) { + return !_btnYes.MouseButtonDownMsg(pt); +} + +bool CPetQuit::MouseButtonUpMsg(const Point &pt) { + CPetControl *pet = getPetControl(); + if (_btnYes.MouseButtonUpMsg(pt) && pet) { + CGameManager *gameManager = pet->getGameManager(); + if (gameManager) + gameManager->_gameState._quitGame = true; + return true; + } else { + return false; + } +} + +void CPetQuit::getTooltip(CPetText *text) { + text->setText("Quit the game."); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_quit.h b/engines/titanic/pet_control/pet_quit.h new file mode 100644 index 0000000000..87d8aefbbf --- /dev/null +++ b/engines/titanic/pet_control/pet_quit.h @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_QUIT_H +#define TITANIC_PET_QUIT_H + +#include "titanic/pet_control/pet_gfx_element.h" +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +class CPetQuit : public CPetGlyph { +private: + CPetText _text; + CPetGfxElement _btnYes; +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Reset the glyph + */ + virtual bool reset(); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); + + /** + * Get a reference to the tooltip text associated with the section + */ + virtual CPetText *getText() { return &_text; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_QUIT_H */ diff --git a/engines/titanic/pet_control/pet_real_life.cpp b/engines/titanic/pet_control/pet_real_life.cpp new file mode 100644 index 0000000000..b9e1990dd2 --- /dev/null +++ b/engines/titanic/pet_control/pet_real_life.cpp @@ -0,0 +1,129 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_real_life.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_load.h" +#include "titanic/pet_control/pet_save.h" +#include "titanic/pet_control/pet_sound.h" +#include "titanic/pet_control/pet_quit.h" + +namespace Titanic { + +bool CPetRealLife::setup(CPetControl *petControl) { + if (petControl && setupControl(petControl)) + return reset(); + return false; +} + +bool CPetRealLife::reset() { + _glyphs.reset(); + uint col = getColor(0); + _text.setColor(col); + _text.setLineColor(0, col); + + return true; +} + +void CPetRealLife::draw(CScreenManager *screenManager) { + _petControl->drawSquares(screenManager, 4); + _glyphs.draw(screenManager); + _text.draw(screenManager); +} + +bool CPetRealLife::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return _glyphs.MouseButtonDownMsg(msg->_mousePos); +} + +bool CPetRealLife::MouseDragStartMsg(CMouseDragStartMsg *msg) { + return _glyphs.MouseDragStartMsg(msg); +} + +bool CPetRealLife::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + return _glyphs.MouseDragMoveMsg(msg); +} + +bool CPetRealLife::MouseDragEndMsg(CMouseDragEndMsg *msg) { + return _glyphs.MouseDragEndMsg(msg); +} + +bool CPetRealLife::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + return _glyphs.MouseButtonUpMsg(msg->_mousePos); +} + +bool CPetRealLife::KeyCharMsg(CKeyCharMsg *msg) { + _glyphs.KeyCharMsg(msg->_key); + return true; +} + +bool CPetRealLife::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + return _glyphs.VirtualKeyCharMsg(msg); +} + +void CPetRealLife::postLoad() { + reset(); +} + +bool CPetRealLife::isValid(CPetControl *petControl) { + setupControl(petControl); + return true; +} + +void CPetRealLife::enter(PetArea oldArea) { + _glyphs.enterHighlighted(); +} + +void CPetRealLife::leave() { + _glyphs.leaveHighlighted(); +} + +bool CPetRealLife::setupControl(CPetControl *petControl) { + if (petControl) { + _petControl = petControl; + _glyphs.setup(4, this); + _glyphs.setFlags(6); + + addButton(new CPetLoad()); + addButton(new CPetSave()); + addButton(new CPetSound()); + addButton(new CPetQuit()); + + Rect textRect(0, 0, 276, 30); + textRect.moveTo(32, 436); + _text.setBounds(textRect); + _text.setHasBorder(false); + _text.setup(); + } + + return true; +} + +void CPetRealLife::addButton(CPetGlyph *glyph) { + if (glyph) { + if (glyph->setup(_petControl, &_glyphs)) + _glyphs.push_back(glyph); + } +} + + + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_real_life.h b/engines/titanic/pet_control/pet_real_life.h new file mode 100644 index 0000000000..40bc87d9b5 --- /dev/null +++ b/engines/titanic/pet_control/pet_real_life.h @@ -0,0 +1,138 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_REAL_LIFE_H +#define TITANIC_PET_REAL_LIFE_H + +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +class CPetSaveGlyphs : public CPetGlyphs { +}; + +class CPetRealLife : public CPetSection { +private: + CPetGlyphs _glyphs; + CPetText _text; +private: + /** + * Does setup + */ + bool setupControl(CPetControl *petControl); + + /** + * Adds one of the four button glyphs for display + */ + void addButton(CPetGlyph *glyph); +public: + virtual ~CPetRealLife() {} + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Reset the section + */ + virtual bool reset(); + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Get the bounds for the section + */ + virtual Rect getBounds() const { return Rect(); } + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg); + virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg); + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + virtual bool KeyCharMsg(CKeyCharMsg *msg); + virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + + /** + * Returns item a drag-drop operation has dropped on, if any + */ + virtual CGameObject *dragEnd(const Point &pt) const { return nullptr; } + + /** + * Display a message + */ + virtual void displayMessage(const CString &msg) {} + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param) {} + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) {} + + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea); + + /** + * Called when a section is being left, to switch to another area + */ + virtual void leave(); + + /** + * Called when a new room is entered + */ + virtual void enterRoom(CRoomItem *room) {} + + /** + * Get a reference to the tooltip text associated with the section + */ + virtual CPetText *getText() { return &_text; } + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_REAL_LIFE_H */ diff --git a/engines/titanic/pet_control/pet_remote.cpp b/engines/titanic/pet_control/pet_remote.cpp new file mode 100644 index 0000000000..9b43b8dab9 --- /dev/null +++ b/engines/titanic/pet_control/pet_remote.cpp @@ -0,0 +1,495 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_remote.h" +#include "titanic/pet_control/pet_remote_glyphs.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/messages/pet_messages.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +static const byte REMOTE_DATA[] = { + 0x00, 0x02, + GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x01, 0x02, + GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x02, 0x03, + GLYPH_TELEVISION_CONTROL, GLYPH_OPERATE_LIGHTS, GLYPH_SUCCUBUS_DELIVERY, + 0x03, 0x02, + GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x04, 0x02, + GLYPH_TELEVISION_CONTROL, GLYPH_SUCCUBUS_DELIVERY, + 0x05, 0x02, + GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x06, 0x02, + GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x07, 0x03, + GLYPH_TELEVISION_CONTROL, GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x08, 0x01, + GLYPH_SUCCUBUS_DELIVERY, + 0x09, 0x01, + GLYPH_SUCCUBUS_DELIVERY, + 0x0A, 0x02, GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x0B, 0x01, + GLYPH_NAVIGATION_CONTROLLER, + 0x0C, 0x01, + GLYPH_SUCCUBUS_DELIVERY, + 0x0D, 0x01, + GLYPH_SUCCUBUS_DELIVERY, + 0x0E, 0x00, + 0x0F, 0x01, + GLYPH_TELEVISION_CONTROL, + 0x10, 0x03, + GLYPH_GOTO_BOTTOM_OF_WELL, GLYPH_GOTO_STATEROOM, GLYPH_GOTO_TOP_OF_WELL, + 0x11, 0x01, + GLYPH_SUCCUBUS_DELIVERY, + 0x12, 0x00, + 0x13, 0x02, + GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x14, 0x00, + 0x15, 0x02, + GLYPH_SUCCUBUS_DELIVERY, GLYPH_TELEVISION_CONTROL, + 0x16, 0x00, + 0x17, 0x02, + GLYPH_SUMMON_PELLERATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x18, 0x01, + GLYPH_SUCCUBUS_DELIVERY, + 0x19, 0x00, + 0x1A, 0x00, + 0x1B, 0x00, + 0x1C, 0x00, + 0x1D, 0x02, + GLYPH_SUMMON_ELEVATOR, GLYPH_SUCCUBUS_DELIVERY, + 0x1E, 0x0C, + GLYPH_DEPLOY_FLORAL, GLYPH_DEPLOY_FULLY_RELAXATION, GLYPH_DEPLOY_COMFORT, + GLYPH_DEPLOY_MINOR_STORAGE, GLYPH_ENTERTAINMENT_DEVICE, + GLYPH_DEPLOY_MAJOR_RELAXATION, GLYPH_INFLATE_RELAXATION, + GLYPH_DEPLOY_MAINTENANCE, GLYPH_DEPLOY_WORK_SURFACE, + GLYPH_DEPLOY_MINOR_RELAXATION, GLYPH_DEPLOY_SINK, + GLYPH_DEPLOY_MAJOR_STORAGE, + 0x1F, 0x01, + GLYPH_SUCCUBUS_DELIVERY, + 0x20, 0x02, + GLYPH_SUMMON_ELEVATOR, GLYPH_SUMMON_PELLERATOR, + 0x21, 0x00 +}; + +CPetRemote::CPetRemote() : CPetSection() { +} + +bool CPetRemote::setup(CPetControl *petControl) { + if (petControl && setupControl(petControl)) + return reset(); + return false; +} + +bool CPetRemote::reset() { + if (_petControl) { + _onOff.reset("PetSwitchOn", _petControl, MODE_SELECTED); + _onOff.reset("PetSwitchOff", _petControl, MODE_UNSELECTED); + + _up.reset("PetUp", _petControl, MODE_UNSELECTED); + _down.reset("PetDown", _petControl, MODE_UNSELECTED); + + _left.reset("PetLeftUp", _petControl, MODE_SELECTED); + _left.reset("PetLeft", _petControl, MODE_UNSELECTED); + _right.reset("PetRightUp", _petControl, MODE_SELECTED); + _right.reset("PetRight", _petControl, MODE_UNSELECTED); + _top.reset("PetTopUp", _petControl, MODE_SELECTED); + _top.reset("PetTop", _petControl, MODE_UNSELECTED); + _bottom.reset("PetBottomUp", _petControl, MODE_SELECTED); + _bottom.reset("PetBottom", _petControl, MODE_UNSELECTED); + _action.reset("PetActionUp", _petControl, MODE_SELECTED); + _action.reset("PetAction", _petControl, MODE_UNSELECTED); + + _send.reset("PetActSend0", _petControl, MODE_UNSELECTED); + _send.reset("PetActSend1", _petControl, MODE_SELECTED); + _receive.reset("PetActReceive0", _petControl, MODE_UNSELECTED); + _receive.reset("PetActReceive1", _petControl, MODE_SELECTED); + _call.reset("PetActCall0", _petControl, MODE_UNSELECTED); + _call.reset("PetActCall1", _petControl, MODE_SELECTED); + + _items.reset(); + uint col = getColor(0); + _text.setColor(col); + _text.setLineColor(0, col); + } + + return true; +} + +void CPetRemote::draw(CScreenManager *screenManager) { + _petControl->drawSquares(screenManager, 6); + _items.draw(screenManager); + _text.draw(screenManager); +} + +bool CPetRemote::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return _items.MouseButtonDownMsg(msg->_mousePos); +} + +bool CPetRemote::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + return _items.MouseButtonUpMsg(msg->_mousePos); +} + +bool CPetRemote::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + return _items.MouseButtonDownMsg(msg->_mousePos); +} + +bool CPetRemote::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + return _items.VirtualKeyCharMsg(msg); +} + +bool CPetRemote::isValid(CPetControl *petControl) { + return setupControl(petControl); +} + +void CPetRemote::postLoad() { + reset(); + CRoomItem *room = getRoom(); + if (room) + enterRoom(room); +} + +void CPetRemote::enter(PetArea oldArea) { + if (_items.highlighted14()) + _text.setText(CString()); +} + +void CPetRemote::enterRoom(CRoomItem *room) { + clearGlyphs(); + + if (room) { + CString roomName = room->getName(); + int roomIndex = roomIndexOf(roomName); + if (roomIndex != -1) { + Common::Array<uint> indexes; + if (getRemoteData(roomIndex, indexes)) { + loadGlyphs(indexes); + _items.scrollToStart(); + } + } + } +} + +CPetText *CPetRemote::getText() { + return &_text; +} + +CPetGfxElement *CPetRemote::getElement(uint id) { + switch (id) { + case 0: + return &_onOff; + case 1: + return &_up; + case 2: + return &_down; + case 3: + return &_left; + case 4: + return &_right; + case 5: + return &_top; + case 6: + return &_bottom; + case 7: + return &_action; + case 16: + return &_send; + case 17: + return &_receive; + case 18: + return &_call; + default: + return nullptr; + } +} + +void CPetRemote::highlight(int id) { + int highlightIndex = getHighlightIndex((RemoteGlyph)id); + if (highlightIndex != -1) + _items.highlight(highlightIndex); +} + +bool CPetRemote::setupControl(CPetControl *petControl) { + _petControl = petControl; + if (!petControl) + return false; + + _onOff.setBounds(Rect(0, 0, 15, 43)); + _onOff.translate(519, 381); + _up.setBounds(Rect(0, 0, 21, 24)); + _up.translate(551, 381); + _down.setBounds(Rect(0, 0, 21, 24)); + _down.translate(551, 402); + _left.setBounds(Rect(0, 0, 22, 21)); + _left.translate(518, 393); + _right.setBounds(Rect(0, 0, 21, 21)); + _right.translate(560, 393); + _top.setBounds(Rect(0, 0, 21, 22)); + _top.translate(539, 371); + _bottom.setBounds(Rect(0, 0, 21, 22)); + _bottom.translate(539, 414); + _action.setBounds(Rect(0, 0, 21, 21)); + _action.translate(539, 393); + _send.setBounds(Rect(0, 0, 62, 38)); + _send.translate(503, 373); + _receive.setBounds(Rect(0, 0, 62, 38)); + _receive.translate(503, 420); + _call.setBounds(Rect(0, 0, 62, 38)); + _call.translate(503, 383); + + Rect rect(0, 0, 580, 15); + rect.moveTo(32, 445); + _text.setBounds(rect); + _text.setHasBorder(false); + + _items.setup(6, this); + _items.setFlags(19); + return true; +} + +CRoomItem *CPetRemote::getRoom() const { + if (_petControl) { + CGameManager *gameManager = _petControl->getGameManager(); + if (gameManager) + return gameManager->getRoom(); + } + + return nullptr; +} + +int CPetRemote::getHighlightIndex(RemoteGlyph val) { + CRoomItem *room = getRoom(); + if (!room) + return -1; + + int roomIndex = roomIndexOf(room->getName()); + if (roomIndex == -1) + return -1; + + Common::Array<uint> remoteData; + getRemoteData(roomIndex, remoteData); + + // Loop through the data for the room + for (uint idx = 0; idx < remoteData.size(); ++idx) { + if ((RemoteGlyph)remoteData[idx + 1] == val) + return idx; + } + + return -1; +} + +int CPetRemote::roomIndexOf(const CString &name) { + for (int idx = 0; idx < TOTAL_ROOMS; ++idx) { + if (g_vm->_roomNames[idx] == name) + return idx; + } + + return -1; +} + +bool CPetRemote::getRemoteData(int roomIndex, Common::Array<uint> &indexes) { + const byte *p = &REMOTE_DATA[0]; + for (int idx = 0; idx < TOTAL_ROOMS; ++idx) { + if (*p == roomIndex) { + for (int ctr = 0; ctr < *p; ++ctr) + indexes.push_back(p[ctr + 1]); + return true; + } + + p += *(p + 1) + 2; + } + + return false; +} + +bool CPetRemote::loadGlyphs(const Common::Array<uint> &indexes) { + for (uint idx = 0; idx < indexes.size(); ++idx) { + if (!loadGlyph(indexes[idx])) + return false; + } + + return true; +} + +bool CPetRemote::loadGlyph(int glyphIndex) { + CPetRemoteGlyph *glyph = nullptr; + + switch (glyphIndex) { + case GLYPH_SUMMON_ELEVATOR: + glyph = new CSummonElevatorGlyph(); + break; + + case GLYPH_SUMMON_PELLERATOR: + glyph = new CSummonPelleratorGlyph(); + break; + + case GLYPH_TELEVISION_CONTROL: + glyph = new CTelevisionControlGlyph(); + break; + + case GLYPH_ENTERTAINMENT_DEVICE: + glyph = new CEntertainmentDeviceGlyph(); + break; + + case GLYPH_OPERATE_LIGHTS: + glyph = new COperateLightsGlyph(); + break; + + case GLYPH_DEPLOY_FLORAL: + glyph = new CDeployFloralGlyph(); + break; + + case GLYPH_DEPLOY_FULLY_RELAXATION: + glyph = new CDeployFullyRelaxationGlyph(); + break; + + case GLYPH_DEPLOY_COMFORT: + glyph = new CDeployComfortGlyph(); + break; + + case GLYPH_DEPLOY_MINOR_STORAGE: + glyph = new CDeployMinorStorageGlyph(); + break; + + case GLYPH_DEPLOY_MAJOR_RELAXATION: + glyph = new CDeployMajorRelaxationGlyph(); + break; + + case GLYPH_INFLATE_RELAXATION: + glyph = new CInflateRelaxationGlyph(); + break; + + case GLYPH_DEPLOY_MAINTENANCE: + glyph = new CDeployMaintenanceGlyph(); + break; + + case GLYPH_DEPLOY_WORK_SURFACE: + glyph = new CDeployWorkSurfaceGlyph(); + break; + + case GLYPH_DEPLOY_MINOR_RELAXATION: + glyph = new CDeployMinorRelaxationGlyph(); + break; + + case GLYPH_DEPLOY_SINK: + glyph = new CDeploySinkGlyph(); + break; + + case GLYPH_DEPLOY_MAJOR_STORAGE: + glyph = new CDeployMajorStorageGlyph(); + break; + + case GLYPH_SUCCUBUS_DELIVERY: + glyph = new CSuccubusDeliveryGlyph(); + break; + + case GLYPH_NAVIGATION_CONTROLLER: + glyph = new CNavigationControllerGlyph(); + break; + + case GLYPH_GOTO_BOTTOM_OF_WELL: + glyph = new CGotoBottomOfWellGlyph(); + break; + + case GLYPH_GOTO_TOP_OF_WELL: + glyph = new CGotoTopOfWellGlyph(); + break; + + case GLYPH_GOTO_STATEROOM: + glyph = new CGotoStateroomGlyph(); + break; + + case GLYPH_GOTO_BAR: + glyph = new CGotoBarGlyph(); + + case GLYPH_GOTO_PROMENADE: + glyph = new CGotoPromenadeDeckGlyph(); + break; + + case GLYPH_GOTO_ARBORETUM: + glyph = new CGotoArboretumGlyph(); + break; + + case GLYPH_GOTO_MUSIC_ROOM: + glyph = new CGotoMusicRoomGlyph(); + break; + + case GLYPH_GOTO_RESTAURANT: + glyph = new CGotoRestaurantGlyph(); + break; + + default: + break; + } + + if (glyph) { + if (glyph->setup(_petControl, &_items)) { + _items.push_back(glyph); + return true; + } + } + + return false; +} + +void CPetRemote::generateMessage(RemoteMessage msgNum, const CString &name, int num) { + switch (msgNum) { + case RMSG_LEFT: { + CPETLeftMsg msg(name, num); + msg.execute(_petControl->_remoteTarget); + break; + } + + case RMSG_RIGHT: { + CPETRightMsg msg(name, num); + msg.execute(_petControl->_remoteTarget); + break; + } + + case RMSG_UP: { + CPETUpMsg msg(name, num); + msg.execute(_petControl->_remoteTarget); + break; + } + + case RMSG_DOWN: { + CPETDownMsg msg(name, num); + msg.execute(_petControl->_remoteTarget); + break; + } + + case RMSG_ACTIVATE: { + CPETActivateMsg msg(name, num); + msg.execute(_petControl->_remoteTarget); + break; + } + + default: + break; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_remote.h b/engines/titanic/pet_control/pet_remote.h new file mode 100644 index 0000000000..22ea1e05ad --- /dev/null +++ b/engines/titanic/pet_control/pet_remote.h @@ -0,0 +1,159 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_REMOTE_H +#define TITANIC_PET_REMOTE_H + +#include "common/array.h" +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/pet_control/pet_remote_glyphs.h" +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +class CPetRemote : public CPetSection { +private: + CPetRemoteGlyphs _items; + CPetGfxElement _onOff; + CPetGfxElement _up; + CPetGfxElement _down; + CPetGfxElement _left; + CPetGfxElement _right; + CPetGfxElement _top; + CPetGfxElement _bottom; + CPetGfxElement _action; + CPetGfxElement _send; + CPetGfxElement _receive; + CPetGfxElement _call; + CPetText _text; +private: + /** + * Setup the control + */ + bool setupControl(CPetControl *petControl); + + /** + * Get the current room + */ + CRoomItem *getRoom() const; + + /** + * Return a highlight index + */ + int getHighlightIndex(RemoteGlyph val); + + /** + * Return the index of a room name in the master room names list + */ + int roomIndexOf(const CString &name); + + /** + * Return a list of remote action glyph indexes for a given room + */ + bool getRemoteData(int roomIndex, Common::Array<uint> &indexes); + + /** + * Clear the list of rooms glyphs + */ + void clearGlyphs() { _items.clear(); } + + /** + * Load the room glyphs + */ + bool loadGlyphs(const Common::Array<uint> &indexes); + + /** + * Load a single room glyph + */ + bool loadGlyph(int glyphIndex); +public: + CPetRemote(); + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Reset the section + */ + virtual bool reset(); + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); + virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea); + + /** + * Called when a new room is entered + */ + virtual void enterRoom(CRoomItem *room); + + /** + * Get a reference to the tooltip text associated with the section + */ + virtual CPetText *getText(); + + /** + * Get an element from the section by a designated Id + */ + virtual CPetGfxElement *getElement(uint id); + + /** + * Highlights a glyph item in the section + */ + virtual void highlight(int id); + + /** + * Generates a PET message + */ + void generateMessage(RemoteMessage msgNum, const CString &name, int num); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_REMOTE_H */ diff --git a/engines/titanic/pet_control/pet_remote_glyphs.cpp b/engines/titanic/pet_control/pet_remote_glyphs.cpp new file mode 100644 index 0000000000..6b7c8cb4ae --- /dev/null +++ b/engines/titanic/pet_control/pet_remote_glyphs.cpp @@ -0,0 +1,562 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_remote_glyphs.h" +#include "titanic/pet_control/pet_remote.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/messages/pet_messages.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CPetRemote *CPetRemoteGlyphs::getOwner() const { + return static_cast<CPetRemote *>(_owner); +} + +void CPetRemoteGlyphs::generateMessage(RemoteMessage msgNum, const CString &name, int num) { + getOwner()->generateMessage(msgNum, name, num); +} + +/*------------------------------------------------------------------------*/ + +void CPetRemoteGlyph::setDefaults(const CString &name, CPetControl *petControl) { + _element.setBounds(Rect(0, 0, 52, 52)); + _element.setup(MODE_UNSELECTED, name, petControl); +} + +CPetRemoteGlyphs *CPetRemoteGlyph::getOwner() const { + return static_cast<CPetRemoteGlyphs *>(_owner); +} + +CPetGfxElement *CPetRemoteGlyph::getElement(uint id) const { + CPetRemote *remote = static_cast<CPetRemote *>(_owner->getOwner()); + return remote->getElement(id); +} + +/*------------------------------------------------------------------------*/ + +bool CBasicRemoteGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults(_gfxName, petControl); + if (owner) + _gfxElement = getElement(18); + return true; +} + +void CBasicRemoteGlyph::draw2(CScreenManager *screenManager) { + if (_gfxElement) + _gfxElement->draw(screenManager); +} + +bool CBasicRemoteGlyph::MouseButtonDownMsg(const Point &pt) { + return _gfxElement && _gfxElement->MouseButtonDownMsg(pt); +} + +bool CBasicRemoteGlyph::MouseButtonUpMsg(const Point &pt) { + if (_gfxElement && _gfxElement->MouseButtonUpMsg(pt)) { + getOwner()->generateMessage(RMSG_ACTIVATE, "Lift"); + return true; + } + + return false; +} + +void CBasicRemoteGlyph::getTooltip(CPetText *text) { + text->setText(_tooltip); +} + +/*------------------------------------------------------------------------*/ + +bool CToggleRemoteGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetGlyph::setup(petControl, owner); + if (owner) + _gfxElement = getElement(0); + return true; +} + +void CToggleRemoteGlyph::draw2(CScreenManager *screenManager) { + _gfxElement->setMode(_flag ? MODE_SELECTED : MODE_UNSELECTED); + _gfxElement->draw(screenManager); +} + +bool CToggleRemoteGlyph::elementMouseButtonDownMsg(const Point &pt, int petNum) { + return _gfxElement->MouseButtonDownMsg(pt); +} + +bool CToggleRemoteGlyph::elementMouseButtonUpMsg(const Point &pt, int petNum) { + if (!_gfxElement->MouseButtonUpMsg(pt)) + return false; + + CTreeItem *target = getPetControl()->_remoteTarget; + if (target) { + CPETActivateMsg msg("SGTSelector", petNum); + msg.execute(target); + _flag = !_flag; + _gfxElement->setMode(_flag ? MODE_SELECTED : MODE_UNSELECTED); + } + + return true; +} + +/*------------------------------------------------------------------------*/ + +bool CRemoteGotoGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults(_gfxName, petControl); + + if (owner) + _gfxElement = getElement(7); + + return true; +} + +void CRemoteGotoGlyph::draw2(CScreenManager *screenManager) { + if (_gfxElement) + _gfxElement->draw(screenManager); +} + +bool CRemoteGotoGlyph::MouseButtonDownMsg(const Point &pt) { + return _gfxElement && _gfxElement->MouseButtonDownMsg(pt); +} + +bool CRemoteGotoGlyph::MouseButtonUpMsg(const Point &pt) { + if (!_gfxElement || !_gfxElement->MouseButtonUpMsg(pt)) + return false; + + CPetControl *petControl = getPetControl(); + if (petControl) { + CGameManager *gameManager = petControl->getGameManager(); + + if (gameManager) { + CRoomItem *room = gameManager->getRoom(); + + if (room) { + CTransportMsg msg(g_vm->_roomNames[_roomIndex], 1, 0); + msg.execute(room); + } + } + } + + return true; +} + +void CRemoteGotoGlyph::getTooltip(CPetText *text) { + text->setText(_tooltip); +} + +/*------------------------------------------------------------------------*/ + +bool CTelevisionControlGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults("3PetTV", petControl); + if (owner) { + _up = getElement(1); + _down = getElement(2); + _onOff = getElement(4); + } + + return true; +} + +void CTelevisionControlGlyph::draw2(CScreenManager *screenManager) { + _onOff->setSelected(_flag); + _onOff->draw(screenManager); + _up->draw(screenManager); + _down->draw(screenManager); +} + +bool CTelevisionControlGlyph::MouseButtonDownMsg(const Point &pt) { + if (_onOff && _onOff->MouseButtonDownMsg(pt)) + return true; + if (_up && _up->MouseButtonDownMsg(pt)) + return true; + if (_down && _down->MouseButtonDownMsg(pt)) + return true; + + return false; +} + +bool CTelevisionControlGlyph::MouseButtonUpMsg(const Point &pt) { + if (_onOff && _onOff->MouseButtonUpMsg(pt)) { + _flag = !_flag; + getOwner()->generateMessage(RMSG_ACTIVATE, "Television"); + return true; + } + + if (_up && _up->MouseButtonUpMsg(pt)) { + getOwner()->generateMessage(RMSG_UP, "Television"); + return true; + } + + if (_down && _down->MouseButtonUpMsg(pt)) { + getOwner()->generateMessage(RMSG_DOWN, "Television"); + return true; + } + + return false; +} + +void CTelevisionControlGlyph::getTooltip(CPetText *text) { + text->setText("Television control"); +} + +/*------------------------------------------------------------------------*/ + +bool CEntertainmentDeviceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + if (owner) { + _gfxElement2 = getElement(1); + _gfxElement3 = getElement(2); + } + + return true; +} + +void CEntertainmentDeviceGlyph::draw2(CScreenManager *screenManager) { + CString viewName = getPetControl()->getFullViewName(); + if (viewName == "SGTState.Node 1.S") { + _gfxElement->setSelected(_flag); + _gfxElement->draw(screenManager); + } else if (viewName == "SGTState.Node 4.E") { + _gfxElement->setSelected(_flag2); + _gfxElement->draw(screenManager); + _gfxElement2->draw(screenManager); + _gfxElement3->draw(screenManager); + } +} + +bool CEntertainmentDeviceGlyph::MouseButtonDownMsg(const Point &pt) { + CString viewName = getPetControl()->getFullViewName(); + if (viewName == "SGTState.Node 1.S") { + return elementMouseButtonDownMsg(pt, 4); + } else if (viewName == "SGTState.Node 4.E") { + return _gfxElement->MouseButtonDownMsg(pt) + || _gfxElement2->MouseButtonDownMsg(pt) + || _gfxElement3->MouseButtonDownMsg(pt); + } + + return false; +} + +bool CEntertainmentDeviceGlyph::MouseButtonUpMsg(const Point &pt) { + CString viewName = getPetControl()->getFullViewName(); + if (viewName == "SGTState.Node 1.S") { + return elementMouseButtonUpMsg(pt, 4); + } else if (viewName == "SGTState.Node 4.E") { + if (_gfxElement->MouseButtonUpMsg(pt)) { + _flag2 = !_flag2; + getOwner()->generateMessage(RMSG_ACTIVATE, "Television"); + return true; + } else if (_gfxElement2->MouseButtonUpMsg(pt)) { + getOwner()->generateMessage(RMSG_UP, "Television"); + return true; + } + else if (_gfxElement3->MouseButtonUpMsg(pt)) { + getOwner()->generateMessage(RMSG_DOWN, "Television"); + return true; + } + } + + return false; +} + +void CEntertainmentDeviceGlyph::getTooltip(CPetText *text) { + text->setText("Operate visual entertainment device"); +} + +/*------------------------------------------------------------------------*/ + +bool COperateLightsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults("3PetLights", petControl); + + if (owner) { + _left = getElement(3); + _right = getElement(4); + _up = getElement(5); + _down = getElement(6); + _activate = getElement(7); + } + + return true; +} + +void COperateLightsGlyph::draw2(CScreenManager *screenManager) { + _left->draw(screenManager); + _right->draw(screenManager); + _up->draw(screenManager); + _down->draw(screenManager); + _activate->draw(screenManager); +} + +bool COperateLightsGlyph::MouseButtonDownMsg(const Point &pt) { + if (_left->MouseButtonDownMsg(pt) + || _right->MouseButtonDownMsg(pt) + || _up->MouseButtonDownMsg(pt) + || _down->MouseButtonDownMsg(pt) + || _activate->MouseButtonDownMsg(pt)) + return true; + return true; +} + +bool COperateLightsGlyph::MouseButtonUpMsg(const Point &pt) { + if (_left && _left->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_LEFT, "Light"); + else if (_right && _right->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_RIGHT, "Light"); + else if (_up && _up->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_UP, "Light"); + else if (_down && _down->MouseButtonUpMsg(pt)) + getOwner()->generateMessage(RMSG_DOWN, "Light"); + else + getOwner()->generateMessage(RMSG_ACTIVATE, "Light"); + + return true; +} + +void COperateLightsGlyph::getTooltip(CPetText *text) { + text->setText("Operate the lights"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployFloralGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetVase", petControl); + return true; +} + +void CDeployFloralGlyph::getTooltip(CPetText *text) { + text->setText("Deploy floral enhancement"); +} + + +/*------------------------------------------------------------------------*/ + +bool CDeployFullyRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetBedfoot", petControl); + return true; +} + +void CDeployFullyRelaxationGlyph::getTooltip(CPetText *text) { + text->setText("Deploy fully recumbent relaxation device"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployComfortGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetToilet", petControl); + return true; +} + +void CDeployComfortGlyph::getTooltip(CPetText *text) { + text->setText("Deploy comfort workstation"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployMinorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetDraw", petControl); + return true; +} + +void CDeployMinorStorageGlyph::getTooltip(CPetText *text) { + text->setText("Deploy minor horizontally mobile storage compartment"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployMajorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetArmChair", petControl); + return true; +} + +void CDeployMajorRelaxationGlyph::getTooltip(CPetText *text) { + text->setText("Deploy major semi-recumbent relaxation device"); +} + +/*------------------------------------------------------------------------*/ + +bool CInflateRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetBedhead", petControl); + return true; +} + +void CInflateRelaxationGlyph::getTooltip(CPetText *text) { + text->setText("Inflate fully recumbent relaxation device "); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployMaintenanceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetWashstand", petControl); + return true; +} + +void CDeployMaintenanceGlyph::getTooltip(CPetText *text) { + text->setText("Deploy personal maintenance hub"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployWorkSurfaceGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetTable", petControl); + return true; +} + +void CDeployWorkSurfaceGlyph::getTooltip(CPetText *text) { + text->setText("Deploy executive horizontal worksurface"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployMinorRelaxationGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetDeskchair", petControl); + return true; +} + +void CDeployMinorRelaxationGlyph::getTooltip(CPetText *text) { + text->setText("Deploy minor semi-recumbent relaxation device"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeploySinkGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetDeskchair", petControl); + return true; +} + +void CDeploySinkGlyph::getTooltip(CPetText *text) { + text->setText("Deploy aqueous cleansing receptacle"); +} + +/*------------------------------------------------------------------------*/ + +bool CDeployMajorStorageGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CToggleRemoteGlyph::setup(petControl, owner); + setDefaults("3PetChest", petControl); + return true; +} + +void CDeployMajorStorageGlyph::getTooltip(CPetText *text) { + text->setText("Deploy major horizontally mobile storage compartment"); +} + +/*------------------------------------------------------------------------*/ + +bool CSuccubusDeliveryGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults("3PetSuccubus", petControl); + + if (owner) { + _gfxElement1 = getElement(16); + _gfxElement2 = getElement(17); + } + + return true; +} + +void CSuccubusDeliveryGlyph::draw2(CScreenManager *screenManager) { + _gfxElement1->draw(screenManager); + _gfxElement2->draw(screenManager); +} + +bool CSuccubusDeliveryGlyph::MouseButtonDownMsg(const Point &pt) { + return _gfxElement1->MouseButtonDownMsg(pt) + || _gfxElement2->MouseButtonDownMsg(pt); +} + +bool CSuccubusDeliveryGlyph::MouseButtonUpMsg(const Point &pt) { + CTreeItem *target = getPetControl()->_remoteTarget; + + if (_gfxElement1 && _gfxElement1->MouseButtonUpMsg(pt)) { + if (target) { + CPETDeliverMsg msg; + msg.execute(target); + } + } else if (_gfxElement2 && _gfxElement2->MouseButtonUpMsg(pt)) { + if (target) { + CPETReceiveMsg msg; + msg.execute(target); + } + } else { + return false; + } + + return true; +} + +void CSuccubusDeliveryGlyph::getTooltip(CPetText *text) { + text->setText("Succ-U-Bus delivery system control"); +} + +/*------------------------------------------------------------------------*/ + +bool CNavigationControllerGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetRemoteGlyph::setup(petControl, owner); + setDefaults("3PetStarField", petControl); + + if (owner) + _gfxElement = getElement(0); + + return true; +} + +void CNavigationControllerGlyph::draw2(CScreenManager *screenManager) { + _gfxElement->setMode(_flag ? MODE_SELECTED : MODE_UNSELECTED); + _gfxElement->draw(screenManager); +} + +bool CNavigationControllerGlyph::MouseButtonDownMsg(const Point &pt) { + return _gfxElement->MouseButtonDownMsg(pt); +} + +bool CNavigationControllerGlyph::MouseButtonUpMsg(const Point &pt) { + if (!_gfxElement->MouseButtonUpMsg(pt)) + return false; + + _flag = !_flag; + CTreeItem *target = getPetControl()->_remoteTarget; + if (target) { + CPETHelmetOnOffMsg msg; + msg.execute(target); + } + + return true; +} + +void CNavigationControllerGlyph::getTooltip(CPetText *text) { + text->setText("Navigation controller"); +} + +/*------------------------------------------------------------------------*/ + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_remote_glyphs.h b/engines/titanic/pet_control/pet_remote_glyphs.h new file mode 100644 index 0000000000..d3541d6a94 --- /dev/null +++ b/engines/titanic/pet_control/pet_remote_glyphs.h @@ -0,0 +1,715 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_REMOTE_GLYPHS_H +#define TITANIC_PET_REMOTE_GLYPHS_H + +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/pet_control/pet_gfx_element.h" + +namespace Titanic { + +enum RemoteGlyph { + GLYPH_SUMMON_ELEVATOR = 0, GLYPH_SUMMON_PELLERATOR = 1, + GLYPH_TELEVISION_CONTROL = 2, GLYPH_ENTERTAINMENT_DEVICE = 3, + GLYPH_OPERATE_LIGHTS = 4, GLYPH_DEPLOY_FLORAL = 5, + GLYPH_DEPLOY_FULLY_RELAXATION = 6, GLYPH_DEPLOY_COMFORT = 7, + GLYPH_DEPLOY_MINOR_STORAGE = 8, GLYPH_DEPLOY_MAJOR_RELAXATION = 9, + GLYPH_INFLATE_RELAXATION = 10, GLYPH_DEPLOY_MAINTENANCE = 11, + GLYPH_DEPLOY_WORK_SURFACE = 12, GLYPH_DEPLOY_MINOR_RELAXATION = 13, + GLYPH_DEPLOY_SINK = 14, GLYPH_DEPLOY_MAJOR_STORAGE = 15, + GLYPH_SUCCUBUS_DELIVERY = 16, GLYPH_NAVIGATION_CONTROLLER = 17, + GLYPH_GOTO_BOTTOM_OF_WELL = 18, GLYPH_GOTO_TOP_OF_WELL = 19, + GLYPH_GOTO_STATEROOM = 20, GLYPH_GOTO_BAR = 21, + GLYPH_GOTO_PROMENADE = 22, GLYPH_GOTO_ARBORETUM = 23, + GLYPH_GOTO_MUSIC_ROOM = 24, GLYPH_GOTO_RESTAURANT = 25 +}; + +enum RemoteMessage { + RMSG_LEFT = 0, RMSG_RIGHT = 1, RMSG_UP = 2, RMSG_DOWN = 3, RMSG_ACTIVATE = 4 +}; + +class CPetRemote; + +class CPetRemoteGlyphs : public CPetGlyphs { +public: + /** + * Returns the owning CPetRemote + */ + CPetRemote *getOwner() const; + + /** + * Generates a PET message + */ + void generateMessage(RemoteMessage msgNum, const CString &name, int num = -1); +}; + +class CPetRemoteGlyph : public CPetGlyph { +protected: + CPetGfxElement *_gfxElement; +protected: + CPetRemoteGlyph() : CPetGlyph(), _gfxElement(nullptr) {} + + /** + * Set defaults for the glyph + */ + void setDefaults(const CString &name, CPetControl *petControl); + + /** + * Get the owner + */ + CPetRemoteGlyphs *getOwner() const; + + /** + * Get an element by id from the parent Remote section + */ + CPetGfxElement *getElement(uint id) const; +}; + +class CBasicRemoteGlyph : public CPetRemoteGlyph { +private: + CString _gfxName, _tooltip, _msgString; +public: + CBasicRemoteGlyph(const CString &gfxName, const CString &tooltip, + const CString &msgString) : CPetRemoteGlyph(), + _gfxName(gfxName), _tooltip(tooltip), _msgString(msgString) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CToggleRemoteGlyph : public CPetRemoteGlyph { +protected: + CPetGfxElement *_gfxElement; + bool _flag; +public: + CToggleRemoteGlyph() : CPetRemoteGlyph(), _gfxElement(nullptr), _flag(false) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages to the default element + */ + bool elementMouseButtonDownMsg(const Point &pt, int petNum); + + /** + * Called for mouse button up messages to the default element + */ + bool elementMouseButtonUpMsg(const Point &pt, int petNum); +}; + +class CRemoteGotoGlyph : public CPetRemoteGlyph { +protected: + int _roomIndex; + CPetGfxElement *_gfxElement; + CString _gfxName, _tooltip; +public: + CRemoteGotoGlyph() : CPetRemoteGlyph(), _gfxElement(nullptr), _roomIndex(21) {} + CRemoteGotoGlyph(const CString &gfxName, const CString &tooltip) : + CPetRemoteGlyph(), _gfxElement(nullptr), _roomIndex(21), + _gfxName(gfxName), _tooltip(tooltip) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CSummonElevatorGlyph : public CBasicRemoteGlyph { +public: + CSummonElevatorGlyph() : CBasicRemoteGlyph( + "3PetLift", "Summon Elevator", "Lift") {} +}; + +class CSummonPelleratorGlyph : public CBasicRemoteGlyph { +public: + CSummonPelleratorGlyph() : CBasicRemoteGlyph( + "3PetPellerator", "Summon Pellerator", "Pellerator") {} +}; + +class CTelevisionControlGlyph : public CPetRemoteGlyph { +private: + bool _flag; + CPetGfxElement *_up, *_down, *_onOff; +public: + CTelevisionControlGlyph() : CPetRemoteGlyph(), _flag(false), + _up(nullptr), _down(nullptr), _onOff(nullptr) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CEntertainmentDeviceGlyph : public CToggleRemoteGlyph { +public: + bool _flag2; + CPetGfxElement *_gfxElement2, *_gfxElement3; +public: + CEntertainmentDeviceGlyph() : CToggleRemoteGlyph(), + _flag2(false), _gfxElement2(nullptr), _gfxElement3(nullptr) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + + +class COperateLightsGlyph : public CPetRemoteGlyph { +public: + CPetGfxElement *_left, *_right, *_up, *_down, *_activate; +public: + COperateLightsGlyph() : CPetRemoteGlyph(), _left(nullptr), _right(nullptr), + _up(nullptr), _down(nullptr), _activate(nullptr) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployFloralGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 0); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 0); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployFullyRelaxationGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 1); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 1); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployComfortGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 2); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 2); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployMinorStorageGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 3); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 3); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployMajorRelaxationGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 5); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 5); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CInflateRelaxationGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 6); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 6); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployMaintenanceGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 7); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 7); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployWorkSurfaceGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 8); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 8); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployMinorRelaxationGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 9); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 9); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeploySinkGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 10); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 10); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CDeployMajorStorageGlyph : public CToggleRemoteGlyph { +public: + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt) { + return elementMouseButtonDownMsg(pt, 11); + } + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt) { + return elementMouseButtonUpMsg(pt, 11); + } + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CSuccubusDeliveryGlyph : public CPetRemoteGlyph { +private: + CPetGfxElement *_gfxElement1, *_gfxElement2; +public: + CSuccubusDeliveryGlyph() : CPetRemoteGlyph(), + _gfxElement1(nullptr), _gfxElement2(nullptr) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CNavigationControllerGlyph : public CPetRemoteGlyph { +private: + bool _flag; + CPetGfxElement *_gfxElement; +public: + CNavigationControllerGlyph() : CPetRemoteGlyph(), + _flag(false), _gfxElement(nullptr) {} + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +class CGotoBottomOfWellGlyph : public CRemoteGotoGlyph { +public: + CGotoBottomOfWellGlyph() : CRemoteGotoGlyph("3PetBotOfWell", + "Go to the Bottom of the Well") {} +}; + +class CGotoTopOfWellGlyph : public CRemoteGotoGlyph { +public: + CGotoTopOfWellGlyph() : CRemoteGotoGlyph("3PetTopOfWell", + "Go to the Top of the Well") {} +}; + +class CGotoStateroomGlyph : public CRemoteGotoGlyph { +public: + CGotoStateroomGlyph() : CRemoteGotoGlyph("3PetRoom", + "Go to your stateroom") {} +}; + +class CGotoBarGlyph : public CRemoteGotoGlyph { +public: + CGotoBarGlyph() : CRemoteGotoGlyph("3PetBar", + "Go to the Bar") {} +}; + +class CGotoPromenadeDeckGlyph : public CRemoteGotoGlyph { +public: + CGotoPromenadeDeckGlyph() : CRemoteGotoGlyph("3PetPromDeck", + "Go to the Promenade Deck") {} +}; + +class CGotoArboretumGlyph : public CRemoteGotoGlyph { +public: + CGotoArboretumGlyph() : CRemoteGotoGlyph("3PetArboretum", + "Go to the Arboretum") {} +}; + +class CGotoMusicRoomGlyph : public CRemoteGotoGlyph { +public: + CGotoMusicRoomGlyph() : CRemoteGotoGlyph("3PetMusicRoom", + "Go to the Music Room") {} +}; + +class CGotoRestaurantGlyph : public CRemoteGotoGlyph { +public: + CGotoRestaurantGlyph() : CRemoteGotoGlyph("3Pet1stClassRest", + "Go to the First Class Restaurant") {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_REMOTE_GLYPHS_H */ diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp new file mode 100644 index 0000000000..2415c96966 --- /dev/null +++ b/engines/titanic/pet_control/pet_rooms.cpp @@ -0,0 +1,380 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_rooms.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +CPetRooms::CPetRooms() : + _chevLeftOnDim(nullptr), _chevLeftOffDim(nullptr), + _chevRightOnDim(nullptr), _chevRightOffDim(nullptr), + _chevLeftOnLit(nullptr), _chevLeftOffLit(nullptr), + _chevRightOnLit(nullptr), _chevRightOffLit(nullptr), + _floorNum(0), _elevatorNum(0), _roomNum(0), _field1CC(0), + _wellEntry(0), _field1D4(0) { +} + +bool CPetRooms::setup(CPetControl *petControl) { + if (petControl && setupControl(petControl)) + return reset(); + return false; +} + +bool CPetRooms::reset() { + if (_petControl) { + _plinth.reset("PetChevPlinth", _petControl, MODE_UNSELECTED); + _glyphs.reset(); + + uint col = getColor(0); + _text.setColor(col); + _text.setLineColor(0, col); + } + + return true; +} + +void CPetRooms::draw(CScreenManager *screenManager) { + _petControl->drawSquares(screenManager, 6); + _plinth.draw(screenManager); + _glyphItem.drawAt(screenManager, getGlyphPos(), false); + _text.draw(screenManager); +} + +bool CPetRooms::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_glyphs.MouseButtonDownMsg(msg->_mousePos)) + return true; + + if (!_glyphItem.contains(getGlyphPos(), msg->_mousePos)) + return false; + + _glyphItem.MouseButtonDownMsg(msg->_mousePos); + return true; +} + +bool CPetRooms::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (_glyphs.MouseDragStartMsg(msg)) + return true; + + Point topLeft = getGlyphPos(); + if (!_glyphItem.contains(topLeft, msg->_mousePos)) + return false; + + _glyphItem.dragGlyph(topLeft, msg); + return true; +} + +bool CPetRooms::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + return false; +} + +bool CPetRooms::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + return !_glyphs.MouseButtonDownMsg(msg->_mousePos); +} + +bool CPetRooms::VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { + return _glyphs.VirtualKeyCharMsg(msg); +} + +bool CPetRooms::checkDragEnd(CGameObject *item) { + // Ignore any item drops except valid mail items + if (!item->_isMail) + return false; + + uint roomFlags = item->_id; + CPetRoomsGlyph *glyph = _glyphs.findGlyphByFlags(roomFlags); + if (glyph) { + if (_glyphs.findGlyphByFlags(0)) { + _glyphs.highlight(glyph); + return false; + } + + roomFlags = 0; + } + + addRoom(roomFlags, true); + return false; +} + +void CPetRooms::displayMessage(const CString &msg) { + _glyphs.resetHighlight(); + CPetSection::displayMessage(msg); +} + +bool CPetRooms::isValid(CPetControl *petControl) { + return setupControl(petControl); +} + +void CPetRooms::load(SimpleFile *file, int param) { + if (!param) { + int count = file->readNumber(); + + for (int idx = 0; idx < count; ++idx) { + CPetRoomsGlyph *glyph = addGlyph(file->readNumber(), false); + glyph->setMode((RoomGlyphMode)file->readNumber()); + } + + _glyphItem.setMode((RoomGlyphMode)file->readNumber()); + file->readNumber(); + _floorNum = file->readNumber(); + _elevatorNum = file->readNumber(); + _roomNum = file->readNumber(); + _field1CC = file->readNumber(); + _wellEntry = file->readNumber(); + _field1D4 = file->readNumber(); + } +} + +void CPetRooms::postLoad() { + reset(); +} + +void CPetRooms::save(SimpleFile *file, int indent) { + _glyphs.saveGlyphs(file, indent); + _glyphItem.saveGlyph(file, indent); + file->writeNumberLine(_floorNum, indent); + file->writeNumberLine(_elevatorNum, indent); + file->writeNumberLine(_roomNum, indent); + file->writeNumberLine(_field1CC, indent); + file->writeNumberLine(_wellEntry, indent); + file->writeNumberLine(_field1D4, indent); +} + +void CPetRooms::enter(PetArea oldArea) { + if (!_glyphs.highlighted14()) + _text.setText(""); +} + +void CPetRooms::enterRoom(CRoomItem *room) { + +} + +CPetText *CPetRooms::getText() { + return &_text; +} + +CGameObject *CPetRooms::getBackground(int index) const { + switch (index) { + case 8: + return _chevLeftOnDim; + case 9: + return _chevLeftOffDim; + case 10: + return _chevLeftOnLit; + case 11: + return _chevLeftOffLit; + case 12: + return _chevRightOnDim; + case 13: + return _chevRightOffDim; + case 14: + return _chevRightOnLit; + case 15: + return _chevRightOffLit; + default: + return nullptr; + } +} + +bool CPetRooms::setupControl(CPetControl *petControl) { + _petControl = petControl; + if (!petControl) + return false; + + Rect rect1(0, 0, 470, 15); + rect1.moveTo(32, 445); + _text.setBounds(rect1); + _text.setHasBorder(false); + + Rect rect2(0, 0, 81, 81); + _plinth.setBounds(rect2); + _plinth.translate(494, 374); + + _chevLeftOnDim = petControl->getHiddenObject("3PetChevLeftOnDim"); + _chevLeftOffDim = petControl->getHiddenObject("3PetChevLeftOffDim"); + _chevRightOnDim = petControl->getHiddenObject("3PetChevRightOnDim"); + _chevRightOffDim = petControl->getHiddenObject("3PetChevRightOffDim"); + _chevLeftOnLit = petControl->getHiddenObject("3PetChevLeftOnLit"); + _chevLeftOffLit = petControl->getHiddenObject("3PetChevLeftOffLit"); + _chevRightOnLit = petControl->getHiddenObject("3PetChevRightOnLit"); + _chevRightOffLit = petControl->getHiddenObject("3PetChevRightOffLit"); + + _glyphs.setup(6, this); + _glyphs.setFlags(GFLAG_16); + _glyphItem.setup(petControl, &_glyphs); + _glyphItem.set38(1); + return true; +} + +void CPetRooms::resetHighlight() { + _glyphItem.setRoomFlags(getRoomFlags()); + _glyphs.resetHighlight(); + _glyphItem.updateTooltip(); + areaChanged(PET_ROOMS); +} + +uint CPetRooms::getRoomFlags() const { + CRoomFlags roomFlags; + CString roomName = _petControl->getRoomName(); + + uint flags = roomFlags.getSpecialRoomFlags(roomName); + if (flags) + return flags; + + int classNum = roomFlags.whatPassengerClass(_floorNum); + roomFlags.setPassengerClassBits(classNum); + roomFlags.setFloorNum(_floorNum); + + switch (classNum) { + case 1: + roomFlags.setElevatorNum(_elevatorNum); + roomFlags.setRoomBits(_roomNum); + break; + + case 2: + if (_roomNum > 0) { + if (_roomNum >= 3) { + roomFlags.setElevatorNum(_elevatorNum == 1 || _elevatorNum == 2 ? 1 : 3); + } else { + roomFlags.setElevatorNum(_elevatorNum == 1 || _elevatorNum == 2 ? 2 : 4); + } + + roomFlags.setRoomBits(((_roomNum - 1) & 1) + (_field1CC > 1 ? 3 : 2)); + } else { + roomFlags.setRoomBits(0); + } + break; + + case 3: + roomFlags.setElevatorNum(_elevatorNum); + roomFlags.setRoomBits(_roomNum + _field1CC * 6 - 6); + break; + + default: + break; + } + + return roomFlags.get(); +} + +void CPetRooms::reassignRoom(int passClassNum) { + CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom(); + if (glyph) + // Flag the old assigned room as no longer assigned + glyph->setMode(RGM_PREV_ASSIGNED_ROOM); + + CRoomFlags roomFlags; + roomFlags.setRandomLocation(passClassNum, _field1D4); + glyph = addRoom(roomFlags, true); + if (glyph) { + // Flag the new room as assigned to the player, and highlight it + glyph->setMode(RGM_ASSIGNED_ROOM); + _glyphs.highlight(glyph); + } +} + +CPetRoomsGlyph *CPetRooms::addRoom(uint roomFlags, bool highlight_) { + // Ensure that we don't add room if the room is already present + if (_glyphs.hasFlags(roomFlags)) + return nullptr; + + if (_glyphs.size() >= 32) + // Too many rooms already + return nullptr; + + // Do a preliminary scan of the glyph list for any glyph that is + // no longer valid, and thus can be removed + for (CPetRoomsGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) { + CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i); + if (!glyph->isAssigned()) { + _glyphs.erase(i); + break; + } + } + + // Add the glyph + return addGlyph(roomFlags, highlight_); +} + +CPetRoomsGlyph *CPetRooms::addGlyph(uint roomFlags, bool highlight_) { + CPetRoomsGlyph *glyph = new CPetRoomsGlyph(roomFlags); + if (!glyph->setup(_petControl, &_glyphs)) { + delete glyph; + return nullptr; + } else { + _glyphs.push_back(glyph); + if (highlight_) + _glyphs.highlight(glyph); + + return glyph; + } +} + +bool CPetRooms::changeLocationClass(int newClassNum) { + CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom(); + if (!glyph) + return 0; + + glyph->changeLocation(newClassNum); + return true; +} + +bool CPetRooms::hasRoomFlags(uint roomFlags) const { + for (CPetRoomsGlyphs::const_iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) { + const CPetRoomsGlyph *glyph = static_cast<const CPetRoomsGlyph *>(*i); + if (glyph->isAssigned() && glyph->getRoomFlags() == roomFlags) + return true; + } + + return false; +} + +uint CPetRooms::getAssignedRoomFlags() const { + CPetRoomsGlyph *glyph = _glyphs.findAssignedRoom(); + return glyph ? glyph->getRoomFlags() : 0; +} + +int CPetRooms::getAssignedRoomNum() const { + uint flags = getAssignedRoomFlags(); + if (!flags) + return 0; + + return CRoomFlags(flags).getRoomNum(); +} + +int CPetRooms::getAssignedFloorNum() const { + uint flags = getAssignedRoomFlags(); + if (!flags) + return 0; + + return CRoomFlags(flags).getFloorNum(); +} + +int CPetRooms::getAssignedElevatorNum() const { + uint flags = getAssignedRoomFlags(); + if (!flags) + return 0; + + return CRoomFlags(flags).getElevatorNum(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_rooms.h b/engines/titanic/pet_control/pet_rooms.h new file mode 100644 index 0000000000..af1ea2ae4f --- /dev/null +++ b/engines/titanic/pet_control/pet_rooms.h @@ -0,0 +1,219 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_ROOMS_H +#define TITANIC_PET_ROOMS_H + +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_text.h" +#include "titanic/pet_control/pet_rooms_glyphs.h" + +namespace Titanic { + +class CPetRooms : public CPetSection { +private: + CPetRoomsGlyphs _glyphs; + CPetRoomsGlyph _glyphItem; + CGameObject *_chevLeftOnDim; + CGameObject *_chevLeftOffDim; + CGameObject *_chevRightOnDim; + CGameObject *_chevRightOffDim; + CGameObject *_chevLeftOnLit; + CGameObject *_chevLeftOffLit; + CGameObject *_chevRightOnLit; + CGameObject *_chevRightOffLit; + CPetGfxElement _plinth; + CPetText _text; + int _floorNum; + int _elevatorNum; + int _roomNum; + int _field1CC; + int _wellEntry; + int _field1D4; +private: + /** + * Setup the control + */ + bool setupControl(CPetControl *petControl); + + /** + * Returns the glyth position + */ + Point getGlyphPos() const { return Point(509, 388); } + + /** + * Adds a glyph to the list + */ + CPetRoomsGlyph *addRoom(uint roomFlags, bool highlight); + + /** + * Adds a glyph to the list + */ + CPetRoomsGlyph *addGlyph(uint roomFlags, bool highlight); +public: + CPetRooms(); + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Reset the section + */ + virtual bool reset(); + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg); + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); + virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg); + + /** + * Check whether a drag drop can occur + */ + virtual bool checkDragEnd(CGameObject *item); + + /** + * Display a message + */ + virtual void displayMessage(const CString &msg); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param); + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea); + + /** + * Called when a new room is entered + */ + virtual void enterRoom(CRoomItem *room); + + /** + * Get a reference to the tooltip text associated with the section + */ + virtual CPetText *getText(); + + /** + * Special retrieval of glyph background image + */ + virtual CGameObject *getBackground(int index) const; + + /** + * Reset the highlight + */ + void resetHighlight(); + + /** + * Gives the player a new assigned room in the specified passenger class + */ + void reassignRoom(int passClassNum); + + /** + * Change the current location passenger class + */ + bool changeLocationClass(int newClassNum); + + /** + * Returns true if a room glyph exists with the given flags + */ + bool hasRoomFlags(uint roomFlags) const; + + /** + * Returns the room flags for the player's currently assigned room + */ + uint getAssignedRoomFlags() const; + + /** + * Returns the room number for the player's currently assigned room + */ + int getAssignedRoomNum() const; + + /** + * Returns the floor number for the player's currently assigned room + */ + int getAssignedFloorNum() const; + + /** + * Returns the elevator number for the player's currently assigned room + */ + int getAssignedElevatorNum() const; + + /** + * Gets room flags to use for glyphs + */ + uint getRoomFlags() const; + + void setFloorNum(int floorNum) { _floorNum = floorNum; } + int getFloorNum() const { return _floorNum; } + void setElevatorNum(int elevNum) { _elevatorNum = elevNum; } + int getElevatorNum() const { return _elevatorNum; } + void setRoomNum(int roomNum) { _roomNum = roomNum; } + int getRoomNum() const { return _roomNum; } + void set1CC(int val) { _field1CC = val; } + int get1CC() const { return _field1CC; } + + /** + * Sets the entry number for arriving at the well + */ + void setWellEntry(int val) { _wellEntry = val; } + + /** + * Gets the entry number used when last arriving at the well + */ + int getWellEntry() const { return _wellEntry; } + + void set1D4(int val) { _field1D4 = val; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_ROOMS_SECTION_H */ diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp new file mode 100644 index 0000000000..d9e19b1f67 --- /dev/null +++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_rooms_glyphs.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_section.h" +#include "titanic/support/screen_manager.h" +#include "titanic/room_flags.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CPetRoomsGlyph::CPetRoomsGlyph() : CPetGlyph(), + _roomFlags(0), _field38(0), _mode(RGM_UNASSIGNED), + _object0(nullptr), _object1(nullptr), _object2(nullptr), _object3(nullptr), + _object4(nullptr), _object5(nullptr), _object6(nullptr), _object7(nullptr) { +} + +CPetRoomsGlyph::CPetRoomsGlyph(uint flags) : CPetGlyph(), + _roomFlags(flags), _field38(0), _mode(RGM_UNASSIGNED), + _object0(nullptr), _object1(nullptr), _object2(nullptr), _object3(nullptr), + _object4(nullptr), _object5(nullptr), _object6(nullptr), _object7(nullptr) { +} + +bool CPetRoomsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { + if (!CPetGlyph::setup(petControl, owner)) + return false; + + CPetSection *section = owner->getOwner(); + _object0 = section->getBackground(9); + _object1 = section->getBackground(12); + _object4 = section->getBackground(13); + _object5 = section->getBackground(10); + _object2 = section->getBackground(11); + _object3 = section->getBackground(14); + _object6 = section->getBackground(15); + _object7 = _object6; + return true; +} + +void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted_) { + // Clear background + Rect rect(pt.x, pt.y, pt.x + 52, pt.y + 52); + screenManager->fillRect(SURFACE_BACKBUFFER, &rect, 0, 0, 0); + + CRoomFlags roomFlags(_roomFlags); + uint elevBits = roomFlags.getElevatorBits(); + uint classBits = roomFlags.getPassengerClassBits(); + uint floorBits = roomFlags.getFloorBits(); + uint roomBits = roomFlags.getRoomBits(); + + // Save a copy of object pointers that may be modified + CGameObject *obj0 = _object0; + CGameObject *obj1 = _object1; + CGameObject *obj4 = _object4; + CGameObject *obj5 = _object5; + + if (_field38 == 1 || isHighlighted_) { + _object0 = _object2; + _object1 = _object3; + _object4 = _object6; + _object5 = _object7; + } + + // Draw the images + Point destPt = pt; + drawObjects(classBits + elevBits * 4, destPt, screenManager); + destPt.y += 10; + drawObjects((floorBits >> 4) & 15, destPt, screenManager); + destPt.y += 10; + drawObjects(floorBits & 15, destPt, screenManager); + destPt.y += 10; + drawObjects(roomBits >> 3, destPt, screenManager); + destPt.y += 7; + drawObjects(((roomBits & 7) << 1) + (roomFlags.getBit0() ? 1 : 0), + destPt, screenManager); + + // Restore original object pointers + _object0 = obj0; + _object1 = obj1; + _object4 = obj4; + _object5 = obj5; +} + +void CPetRoomsGlyph::selectGlyph(const Point &topLeft, const Point &pt) { + if (isAssigned()) { + bool isShiftPressed = g_vm->_window->getSpecialButtons() & MK_SHIFT; + + if (isShiftPressed) { + int selection = getSelection(topLeft, pt); + if (selection >= 0) + _roomFlags |= 1 << selection; + } + + updateTooltip(); + } +} + +bool CPetRoomsGlyph::dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg) { + bool isShiftPressed = g_vm->_window->getSpecialButtons() & MK_SHIFT; + CPetControl *petControl = getPetControl(); + + if (!isShiftPressed && petControl) { + CGameObject *chevron = petControl->getHiddenObject("3PetChevron"); + + if (chevron) { + chevron->_id = _roomFlags; + chevron->_isMail = _field38; + petControl->removeFromInventory(chevron, false, false); + chevron->loadSurface(); + + chevron->dragMove(msg->_mousePos); + msg->_handled = true; + + if (msg->execute(chevron)) + return true; + } + } + + return false; +} + +void CPetRoomsGlyph::getTooltip(CPetText *text) { + CRoomFlags roomFlags(_roomFlags); + CPetRooms *owner = static_cast<CPetRooms *>(getPetSection()); + + CString msg; + if (isCurrentlyAssigned()) { + msg = "Your assigned room: "; + } else if (isPreviouslyAssigned()) { + msg = "A previously assigned room: "; + } else if (!_field38) { + msg = "Saved Chevron: "; + } else if (_field38 == 1 && owner->getRoomFlags() == _roomFlags) { + msg = "Current location: "; + } + + // Get the room description + CString roomStr = roomFlags.getRoomDesc(); + + if (roomStr == "The Elevator") { + int elevNum = owner->getElevatorNum(); + roomStr = CString::format("Elevator %d", elevNum); + } + + roomStr += " (shift-click edits)"; + text->setText(roomStr); +} + +void CPetRoomsGlyph::saveGlyph(SimpleFile *file, int indent) { + file->writeNumberLine(_roomFlags, indent); + file->writeNumberLine(_mode, indent); +} + +bool CPetRoomsGlyph::proc33(CPetGlyph *glyph) { + CPetRoomsGlyph *roomGlyph = static_cast<CPetRoomsGlyph *>(glyph); + + return CPetGlyph::proc33(glyph) && _roomFlags == roomGlyph->_roomFlags; +} + +void CPetRoomsGlyph::loadFlags(SimpleFile *file, int val) { + if (!val) { + _roomFlags = file->readNumber(); + } +} + +void CPetRoomsGlyph::changeLocation(int newClassNum) { + CRoomFlags roomFlags(_roomFlags); + roomFlags.changeLocation(newClassNum); + _roomFlags = roomFlags.get(); +} + +int CPetRoomsGlyph::getSelection(const Point &topLeft, const Point &pt) { + Rect rects[4] = { + Rect(topLeft.x, topLeft.y, topLeft.x + 13, topLeft.y + 10), + Rect(topLeft.x + 13, topLeft.y, topLeft.x + 26, topLeft.y + 10), + Rect(topLeft.x + 26, topLeft.y, topLeft.x + 39, topLeft.y + 10), + Rect(topLeft.x + 39, topLeft.y, topLeft.x + 52, topLeft.y + 10) + }; + + for (int idx = 0, btnIndex = 19; idx < 5; ++idx, btnIndex -= 4) { + // Iterate through each of the four rects, seeing if there's a match. + // If not, move it down to the next row for the next loop iteration + for (int i = 0; i < 4; ++i) { + if (rects[i].contains(pt)) + return btnIndex - i; + + rects[i].translate(0, 10); + } + } + + return -1; +} + +void CPetRoomsGlyph::drawObjects(uint flags, const Point &pt, CScreenManager *screenManager) { + if (_object0 && _object1 && _object4 && _object5) { + Point destPos = pt; + ((flags & 8) ? _object0 : _object5)->draw(screenManager, destPos); + destPos.x += 13; + ((flags & 4) ? _object4 : _object5)->draw(screenManager, destPos); + destPos.x += 13; + ((flags & 2) ? _object0 : _object1)->draw(screenManager, destPos); + destPos.x += 13; + ((flags & 1) ? _object4 : _object5)->draw(screenManager, destPos); + } +} + + +/*------------------------------------------------------------------------*/ + +void CPetRoomsGlyphs::saveGlyphs(SimpleFile *file, int indent) { + file->writeNumberLine(size(), indent); + + for (const_iterator i = begin(); i != end(); ++i) + (*i)->saveGlyph(file, indent); +} + +CPetRoomsGlyph *CPetRoomsGlyphs::findAssignedRoom() const { + for (const_iterator i = begin(); i != end(); ++i) { + CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i); + if (glyph->isCurrentlyAssigned()) + return glyph; + } + + return nullptr; +} + +CPetRoomsGlyph *CPetRoomsGlyphs::findGlyphByFlags(uint flags) const { + for (const_iterator i = begin(); i != end(); ++i) { + CPetRoomsGlyph *glyph = static_cast<CPetRoomsGlyph *>(*i); + if (glyph->getRoomFlags() == flags) + return glyph; + } + + return nullptr; +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h new file mode 100644 index 0000000000..5d0fec84f8 --- /dev/null +++ b/engines/titanic/pet_control/pet_rooms_glyphs.h @@ -0,0 +1,166 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_ROOMS_GLYPHS_H +#define TITANIC_PET_ROOMS_GLYPHS_H + +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +enum RoomGlyphMode { + RGM_UNASSIGNED = 0, RGM_ASSIGNED_ROOM = 1, RGM_PREV_ASSIGNED_ROOM = 2 +}; + +class CPetRoomsGlyph : public CPetGlyph { +private: + uint _roomFlags; + int _field38; + RoomGlyphMode _mode; + CGameObject *_object0; + CGameObject *_object1; + CGameObject *_object2; + CGameObject *_object3; + CGameObject *_object4; + CGameObject *_object5; + CGameObject *_object6; + CGameObject *_object7; +private: + /** + * Find the selected button under the given point, based on the buttons + * starting at a designated top/left position + */ + int getSelection(const Point &topLeft, const Point &pt); + + /** + * Draws the objects + */ + void drawObjects(uint flags, const Point &pt, CScreenManager *screenManager); +public: + CPetRoomsGlyph(); + CPetRoomsGlyph(uint flags); + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Draw the glyph at a specified position + */ + virtual void drawAt(CScreenManager *screenManager, const Point &pt, bool isHighlighted); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager) {} + + /** + * Selects a glyph + */ + virtual void selectGlyph(const Point &topLeft, const Point &pt); + + /** + * Called when a glyph drag starts + */ + virtual bool dragGlyph(const Point &topLeft, CMouseDragStartMsg *msg); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); + + /** + * Saves the data for the glyph + */ + virtual void saveGlyph(SimpleFile *file, int indent); + + virtual bool proc33(CPetGlyph *glyph); + + /** + * Loads flags for the glyph + */ + virtual void loadFlags(SimpleFile *file, int val); + + /** + * Set the room flags for the glyph + */ + void setRoomFlags(uint flags) { _roomFlags = flags; } + + /** + * Get the room flags for the glyph + */ + uint getRoomFlags() const { return _roomFlags; } + + void set38(int val) { _field38 = val; } + + /** + * Sets the mode of the glyph + */ + void setMode(RoomGlyphMode mode) { _mode = mode; } + + void changeLocation(int newClassNum); + + /** + * Returns true if the room is either currently or previously assigned + */ + bool isAssigned() const { return _mode != RGM_UNASSIGNED; } + + /** + * Returns true if the room is the one currently assigned to the player + */ + bool isCurrentlyAssigned() const { return _mode == RGM_ASSIGNED_ROOM; } + + /** + * Returns true if the room was previously assigned to the player + */ + bool isPreviouslyAssigned() const { return _mode == RGM_PREV_ASSIGNED_ROOM; } +}; + +class CPetRoomsGlyphs : public CPetGlyphs { +private: +public: + /** + * Save the list + */ + void saveGlyphs(SimpleFile *file, int indent); + + /** + * Returns the glyph for hte player's assigned room + */ + CPetRoomsGlyph *findAssignedRoom() const; + + /** + * Finds a glyph in the list by it's room flags + */ + CPetRoomsGlyph *findGlyphByFlags(uint flags) const; + + /** + * Returns true if there's a glyph in the list with a given room flags + */ + bool hasFlags(uint flags) const { return findGlyphByFlags(flags) != nullptr; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_ROOMS_GLYPHS_H */ diff --git a/engines/titanic/pet_control/pet_save.cpp b/engines/titanic/pet_control/pet_save.cpp new file mode 100644 index 0000000000..b5e16736bc --- /dev/null +++ b/engines/titanic/pet_control/pet_save.cpp @@ -0,0 +1,72 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_save.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +bool CPetSave::reset() { + CPetLoadSave::reset(); + + CPetControl *pet = getPetControl(); + if (pet) { + setName("PetSave", pet); + _btnLoadSave.reset("PetSaveOut", pet, MODE_UNSELECTED); + _btnLoadSave.reset("PetSaveIn", pet, MODE_SELECTED); + } + + return true; +} + +bool CPetSave::MouseButtonUpMsg(const Point &pt) { + if (_btnLoadSave.MouseButtonUpMsg(pt)) { + execute(); + resetSlots(); + return true; + } else { + return false; + } +} + +void CPetSave::highlightCurrent(const Point &pt) { + resetSlots(); + highlightSave(_savegameSlotNum); +} + +void CPetSave::getTooltip(CPetText *text) { + text->setText("Save the game."); +} + +void CPetSave::highlightSave(int index) { + warning("TODO: CPetSave::highlightSave"); +} + +void CPetSave::unhighlightSave(int index) { + warning("TODO: CPetSave::unhighlightSave"); +} + +void CPetSave::execute() { + warning("TODO: CPetSave::execute"); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_save.h b/engines/titanic/pet_control/pet_save.h new file mode 100644 index 0000000000..54e91e4c76 --- /dev/null +++ b/engines/titanic/pet_control/pet_save.h @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_SAVE_H +#define TITANIC_PET_SAVE_H + +#include "titanic/pet_control/pet_load_save.h" + +namespace Titanic { + +class CPetSave : public CPetLoadSave { +public: + /** + * Reset the glyph + */ + virtual bool reset(); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Unhighlight any currently highlighted element + */ + virtual void unhighlightCurrent() { unhighlightSave(_savegameSlotNum); } + + /** + * Highlight any currently highlighted element + */ + virtual void highlightCurrent(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); + + /** + * Called on a highlighted item when PET area is entered + */ + virtual bool enterHighlighted() { + highlightSave(_savegameSlotNum); + return true; + } + + /** + * Called on a highlighted item when PET area is left + */ + virtual void leaveHighlighted() { unhighlightSave(_savegameSlotNum); } + + /** + * Highlights a save slot + */ + virtual void highlightSave(int index); + + /** + * Unhighlight a save slot + */ + virtual void unhighlightSave(int index); + + /** + * Executes the loading or saving + */ + virtual void execute(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_SAVE_H */ diff --git a/engines/titanic/pet_control/pet_section.cpp b/engines/titanic/pet_control/pet_section.cpp new file mode 100644 index 0000000000..50d6c7615c --- /dev/null +++ b/engines/titanic/pet_control/pet_section.cpp @@ -0,0 +1,109 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +static const uint PALETTE1[6] = { + 0xA7C0DB, 0x9CFFFE, 0x73AEFF, 0xA7C0DB, 0x9CFFFE, 0 +}; + +static const uint PALETTE2[6] = { + 0x10101, 0x1013C, 0xC80101, 0x10101, 0x800101, 0 +}; + +static const uint PALETTE3[5] = { + 0x10101, 0x1013C, 0xC80101, 0x10101, 0x800101 +}; + +void CPetSection::displayMessage(const CString &msg) { + CPetText *text = getText(); + + if (text) { + text->setColor(getColor(1)); + _petControl->makeDirty(); + removeText(5000); + } +} + +void CPetSection::timerExpired(int val) { + if (!val) { + removeText(); + _petControl->makeDirty(); + } +} + +void CPetSection::removeText(int duration) { + if (duration > 0) + _petControl->startPetTimer(0, duration, 0, this); + else + removeText(); +} + +void CPetSection::removeText() { + CPetText *text = getText(); + if (text) + text->setup(); +} + +void CPetSection::stopTextTimer() { + _petControl->stopPetTimer(0); +} + +uint CPetSection::getColor(uint index) { + return getColorTable()[index]; +} + +const uint *CPetSection::getColorTable(int tableNum) { + if (tableNum == -1) { + CPetControl *pet = getPetControl(); + tableNum = pet ? pet->getPassengerClass() : 3; + } + + switch (tableNum) { + case 1: return PALETTE1; + case 2: return PALETTE2; + default: return PALETTE3; + } +} + +void CPetSection::areaChanged(PetArea area) { + if (_petControl && _petControl->_currentArea == area) + _petControl->makeDirty(); +} + +CString CPetSection::getActiveNPCName() const { + if (_petControl && _petControl->_activeNPC) + return _petControl->_activeNPC->getName(); + else + return CString(); +} + +void CPetSection::copyColors(uint tableNum, uint colors[5]) { + const uint *src = getColorTable(tableNum); + Common::copy(src, src + 5, colors); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h new file mode 100644 index 0000000000..8bc427e842 --- /dev/null +++ b/engines/titanic/pet_control/pet_section.h @@ -0,0 +1,250 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_SECTION_H +#define TITANIC_PET_SECTION_H + +#include "titanic/messages/mouse_messages.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +enum PetArea { + PET_INVENTORY = 0, PET_CONVERSATION = 1, PET_REMOTE = 2, + PET_ROOMS = 3, PET_REAL_LIFE = 4, PET_STARFIELD = 5, PET_MESSAGE = 6 +}; + +class CPetControl; +class CPetElement; +class CPetText; +class CScreenManager; +class CRoomItem; + +struct CPetSectionSubData { + int _field0; + int _field4; + int _field8; + int _fieldC; + + CPetSectionSubData() : _field0(0), _field4(0), _field8(0), + _fieldC(0) {} +}; + +class CPetSection { +public: + CPetControl *_petControl; +protected: + /** + * Called when the current area is changed + */ + void areaChanged(PetArea area); + + /** + * Returns the name of the currently active NPC, if any + */ + CString getActiveNPCName() const; + + /** + * Create a color table + */ + void copyColors(uint tableNum, uint colors[5]); +public: + CPetSection() : _petControl(nullptr) {} + virtual ~CPetSection() {} + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl) { return false; } + + /** + * Reset the section + */ + virtual bool reset() { return false; } + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager) {} + + /** + * Get the bounds for the section + */ + virtual Rect getBounds() const { return Rect(); } + + /** + * Called when a general change occurs + */ + virtual void changed(int changeType) {} + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) { return false; } + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg) { return false; } + virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) { return false; } + virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; } + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) { return false; } + virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { return false; } + virtual bool KeyCharMsg(CKeyCharMsg *msg) { return false; } + virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return false; } + + /** + * Check whether a drag drop can occur + */ + virtual bool checkDragEnd(CGameObject *item) { return false; } + + /** + * Returns item a drag-drop operation has dropped on, if any + */ + virtual CGameObject *dragEnd(const Point &pt) const { return nullptr; } + + /** + * Display a message + */ + virtual void displayMessage(const CString &msg); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl) { return false; } + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param) {} + + /** + * Called after a game has been loaded + */ + virtual void postLoad() {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent) {} + + /** + * Called when a section is switched to + */ + virtual void enter(PetArea oldArea) {} + + /** + * Called when a section is being left, to switch to another area + */ + virtual void leave() {} + + virtual void proc23() {} + + /** + * Called when a new room is entered + */ + virtual void enterRoom(CRoomItem *room) {} + + /** + * Called when a previously set up PET timer expires + */ + virtual void timerExpired(int val); + + /** + * Get a reference to the tooltip text associated with the section + */ + virtual CPetText *getText() { return nullptr; } + + /** + * Removes text after a given duration + */ + virtual void removeText(int duration); + + /** + * Removes text after a given duration + */ + virtual void removeText(); + + /** + * Stops the text removal timer + */ + virtual void stopTextTimer(); + + /** + * Get an element from the section by a designated Id + */ + virtual CPetElement *getElement(uint id) { return nullptr; } + + /** + * Special retrieval of glyph background image + */ + virtual CGameObject *getBackground(int index) const { return nullptr; } + + /** + * Display a title for an NPC + */ + virtual void displayNPCName(CGameObject *npc) {} + + virtual void proc33() {} + + /** + * Sets the NPC to use + */ + virtual void setNPC(const CString &name) {} + + /** + * Resets the active NPC + */ + virtual void resetNPC() {} + + /** + * Show the text cursor + */ + virtual void showCursor() {} + + /** + * Hide the text cursor + */ + virtual void hideCursor() {} + + /** + * Highlights a glyph item in the section, if applicable + */ + virtual void highlight(int id) {} + + /** + * Get the PET control + */ + CPetControl *getPetControl() const { return _petControl; } + + /** + * Get a specified color in the currently active UI color table + */ + uint getColor(uint index); + + /** + * Get one of the game's three UI color tables. If the default + * tableNum of -1 is used, the table is taken from the game state + */ + const uint *getColorTable(int tableNum = -1); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_SECTION_H */ diff --git a/engines/titanic/pet_control/pet_slider.cpp b/engines/titanic/pet_control/pet_slider.cpp new file mode 100644 index 0000000000..eb07012f43 --- /dev/null +++ b/engines/titanic/pet_control/pet_slider.cpp @@ -0,0 +1,246 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_slider.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +CPetSlider::CPetSlider() { + _orientation = 0; + _thumbWidth = 0; + _thumbHeight = 0; + _sliderOffset = 0; + _thumbFocused = false; +} + +Rect CPetSlider::clearDirtyArea() { + Rect result = _dirtyArea; + _dirtyArea.clear(); + return result; +} + +bool CPetSlider::checkThumb(const Point &pt) { + _thumbFocused = thumbContains(pt); + if (_thumbFocused) + return true; + else + return containsPt(pt); +} + +bool CPetSlider::resetThumbFocus() { + bool result = _thumbFocused; + _thumbFocused = false; + return result; +} + +bool CPetSlider::MouseDragMoveMsg(const Point &pt) { + int newOffset = calcSliderOffset(pt); + setOffsetPixels(newOffset); + return true; +} + +bool CPetSlider::MouseButtonUpMsg(const Point &pt) { + if (thumbContains(pt)) + return true; + if (!containsPt(pt)) + return false; + + int newOffset = calcSliderOffset(pt); + setOffsetPixels(newOffset); + return true; +} + +bool CPetSlider::contains(const Point &pt) const { + return thumbContains(pt) || containsPt(pt); +} + +double CPetSlider::getOffsetPixels() const { + int maxVal = 0, minVal = 0; + if (_orientation & ORIENTATION_HORIZONTAL) { + maxVal = _slidingRect.right; + minVal = _slidingRect.left; + } + + if (_orientation & ORIENTATION_VERTICAL) { + maxVal = _slidingRect.bottom; + minVal = _slidingRect.top; + } + + if (minVal == maxVal) + return 0.0; + + return _sliderOffset / (maxVal - minVal); +} + +void CPetSlider::setSliderOffset(double offset) { + if (_orientation & ORIENTATION_HORIZONTAL) + _sliderOffset = (int)(offset * (_slidingRect.right - _slidingRect.left)); + + if (_orientation & ORIENTATION_VERTICAL) + _sliderOffset = (int)(offset * (_slidingRect.bottom - _slidingRect.top)); +} + +void CPetSlider::setOffsetPixels(int offset) { + // Add the slider's old position to the dirty area + Rect tempRect = getThumbRect(); + _dirtyArea.combine(tempRect); + + // Set the new offset + _sliderOffset = offset; + + // Add the thumb's new location to the dirty area + tempRect = getThumbRect(); + _dirtyArea.combine(tempRect); +} + +Point CPetSlider::getBackgroundDrawPos() { + return Point(_bounds.left, _bounds.top); +} + +Point CPetSlider::getThumbDrawPos() { + Point thumbPos = getThumbCentroidPos(); + thumbPos -= Point(_thumbWidth / 2, _thumbHeight / 2); + return thumbPos; +} + +Point CPetSlider::getThumbCentroidPos() const { + Point pt; + + if (_orientation & ORIENTATION_HORIZONTAL) { + pt = Point(_slidingRect.left + _sliderOffset, + _slidingRect.top + _slidingRect.height() / 2); + } + + if (_orientation & ORIENTATION_VERTICAL) { + pt = Point(_slidingRect.left + _slidingRect.width() / 2, + _slidingRect.top + _sliderOffset); + } + + return pt; +} + +bool CPetSlider::thumbContains(const Point &pt) const { + return getThumbRect().contains(pt); +} + +Rect CPetSlider::getThumbRect() const { + Rect thumbRect(0, 0, _thumbWidth, _thumbHeight); + Point centroid = getThumbCentroidPos(); + thumbRect.moveTo(centroid.x - _thumbWidth / 2, centroid.y - _thumbHeight / 2); + + return thumbRect; +} + +int CPetSlider::calcSliderOffset(const Point &pt) const { + int result = 0; + + if (_orientation & ORIENTATION_HORIZONTAL) { + result = CLIP(pt.x, _slidingRect.left, _slidingRect.right) - _slidingRect.left; + } + + if (_orientation & ORIENTATION_VERTICAL) { + result = CLIP(pt.y, _slidingRect.top, _slidingRect.bottom) - _slidingRect.top; + } + + return result; +} + +void CPetSlider::setOrientation(SliderOrientation orientation) { + _orientation |= orientation; +} + +void CPetSlider::stepPosition(int direction) { + double val = getOffsetPixels(); + + if (direction == -1) { + val = MAX<double>(val - 0.1, 0.0); + } else if (direction == 1) { + val = MIN<double>(val + 0.1, 1.0); + } + + setSliderOffset(val); +} + +/*------------------------------------------------------------------------*/ + +void CPetSoundSlider::setupBackground(const CString &name, CPetControl *petControl) { + if (petControl) { + _background = petControl->getHiddenObject(name); + } +} + +void CPetSoundSlider::setupThumb(const CString &name, CPetControl *petControl) { + if (petControl) { + _thumb = petControl->getHiddenObject(name); + } +} + +void CPetSoundSlider::setupBackground2(const CString &name, CPetControl *petControl) { + if (petControl) { + CString numStr = "3"; + int mode = petControl->getPassengerClass(); + if (mode <= 3) { + numStr = CString(mode); + } else if (mode == 4) { + mode = petControl->getPriorClass(); + if (mode == 1) { + numStr = CString(mode); + } + } + + CString fullName = numStr + name; + setupBackground(fullName, petControl); + } +} + +void CPetSoundSlider::setupThumb2(const CString &name, CPetControl *petControl) { + if (petControl) { + CString numStr = "3"; + int mode = petControl->getPassengerClass(); + if (mode <= 3) { + numStr = CString(mode); + } else if (mode == 4) { + mode = petControl->getPriorClass(); + if (mode == 1) { + numStr = CString(mode); + } + } + + CString fullName = numStr + name; + setupThumb(fullName, petControl); + } +} + +void CPetSoundSlider::draw(CScreenManager *screenManager) { + if (_background) { + Point pt = getBackgroundDrawPos(); + _background->draw(screenManager, pt); + } + + if (_thumb) { + Point pt = getThumbDrawPos(); + _thumb->draw(screenManager, pt); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_slider.h b/engines/titanic/pet_control/pet_slider.h new file mode 100644 index 0000000000..0bc9e825cd --- /dev/null +++ b/engines/titanic/pet_control/pet_slider.h @@ -0,0 +1,239 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_SLIDER_H +#define TITANIC_PET_SLIDER_H + +#include "titanic/support/rect.h" +#include "titanic/support/string.h" +#include "titanic/core/game_object.h" + +namespace Titanic { + +enum SliderOrientation { ORIENTATION_HORIZONTAL = 1, ORIENTATION_VERTICAL = 2 }; + +class CPetControl; + +class CPetSlider { +private: + int _orientation; + Rect _bounds; + Rect _slidingRect; + int _thumbWidth; + int _thumbHeight; + int _sliderOffset; + bool _thumbFocused; + Rect _dirtyArea; +private: + /** + * Center the center position of the slider's thumb + */ + Point getThumbCentroidPos() const; + + /** + * Returns true if the passed point is within the thumb + */ + bool thumbContains(const Point &pt) const; + + /** + * Gets the area the slider's thumbnail covers + */ + Rect getThumbRect() const; + + /** + * Calculates the slider offset at the specificed position + */ + int calcSliderOffset(const Point &pt) const; +protected: + /** + * Get the position to draw the background at + */ + Point getBackgroundDrawPos(); + + /** + * Get the position to draw the slider thumbnail at + */ + Point getThumbDrawPos(); + + /** + * Returns true if the passed point falls within the slider's bounds + */ + bool containsPt(const Point &pt) const { return _bounds.contains(pt); } +public: + CPetSlider(); + virtual ~CPetSlider() {} + + /** + * Setup the background + */ + virtual void setupBackground(const CString &name, CPetControl *petControl) {} + + /** + * Setup the thumb + */ + virtual void setupThumb(const CString &name, CPetControl *petControl) {} + + /** + * Setup the background + */ + virtual void setupBackground2(const CString &name, CPetControl *petControl) {} + + /** + * Setup the thumb + */ + virtual void setupThumb2(const CString &name, CPetControl *petControl) {} + + /** + * Reset the slider + */ + virtual void reset(const CString &name) {} + + /** + * Draw the slider + */ + virtual void draw(CScreenManager *screenManager) {} + + /** + * Reset the dirty area + */ + virtual Rect clearDirtyArea(); + + /** + * Checks whether the slider is highlighted + */ + virtual bool checkThumb(const Point &pt); + + /** + * Resets the thumb focused flag + */ + virtual bool resetThumbFocus(); + + /** + * Handles dragging the slider + */ + virtual bool MouseDragMoveMsg(const Point &pt); + + /** + * Called when a slider drag ends + */ + virtual bool MouseDragEndMsg(const Point &pt) { return true; } + + /** + * Handles mouse button up messaes + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + virtual bool proc13() { return false; } + virtual bool proc14() { return false; } + + + virtual bool contains(const Point &pt) const; + + /** + * Returns the slider offset in pixels + */ + virtual double getOffsetPixels() const; + + /** + * Sets the slider offset + */ + virtual void setSliderOffset(double offset); + + /** + * Set a new slider offset in pixels + */ + virtual void setOffsetPixels(int offset); + + /** + * Enables a given orientation + */ + void setOrientation(SliderOrientation orientation); + + /** + * Set the bounds for the slider + */ + void setBounds(const Rect &r) { _bounds = r; } + + /** + * Set the sliding bounds for the slider + */ + void setSlidingBounds(const Rect &r) { _slidingRect = r; } + + /** + * Set the size of the slider thumb + */ + void setThumbSize(const Point &pt) { + _thumbWidth = pt.x; + _thumbHeight = pt.y; + } + + /** + * Move the slider + */ + void translate(const Point &pt) { + _bounds.translate(pt.x, pt.y); + _slidingRect.translate(pt.x, pt.y); + } + + /** + * Change the current position of a slider by a step amount + */ + void stepPosition(int direction); +}; + +class CPetSoundSlider : public CPetSlider { +public: + CGameObject *_background; + CGameObject *_thumb; +public: + CPetSoundSlider() : CPetSlider(), _background(nullptr), + _thumb(0) {} + + /** + * Setup the background + */ + virtual void setupBackground(const CString &name, CPetControl *petControl); + + /** + * Setup the thumb + */ + virtual void setupThumb(const CString &name, CPetControl *petControl); + + /** + * Setup the background + */ + virtual void setupBackground2(const CString &name, CPetControl *petControl); + + /** + * Setup the thumb + */ + virtual void setupThumb2(const CString &name, CPetControl *petControl); + + /** + * Draw the slider + */ + virtual void draw(CScreenManager *screenManager); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_SLIDER_H */ diff --git a/engines/titanic/pet_control/pet_sound.cpp b/engines/titanic/pet_control/pet_sound.cpp new file mode 100644 index 0000000000..7bfeb25722 --- /dev/null +++ b/engines/titanic/pet_control/pet_sound.cpp @@ -0,0 +1,282 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_sound.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_real_life.h" +#include "titanic/game_manager.h" + +namespace Titanic { + +CPetSound::CPetSound() : CPetGlyph(), _draggingSlider(nullptr), _draggingSliderNum(0) { +} + +bool CPetSound::setup(CPetControl *petControl, CPetGlyphs *owner) { + CPetGlyph::setup(petControl, owner); + + _masterVolume.setOrientation(ORIENTATION_HORIZONTAL); + _masterVolume.setBounds(Rect(17, 0, 147, 15)); + _masterVolume.setSlidingBounds(Rect(35, 5, 127, 11)); + _masterVolume.setThumbSize(Point(25, 15)); + _masterVolume.translate(Point(415, 376)); + + _musicVolume.setOrientation(ORIENTATION_HORIZONTAL); + _musicVolume.setBounds(Rect(17, 20, 147, 35)); + _musicVolume.setSlidingBounds(Rect(35, 25, 127, 31)); + _musicVolume.setThumbSize(Point(25, 15)); + _musicVolume.translate(Point(415, 376)); + + _parrotVolume.setOrientation(ORIENTATION_HORIZONTAL); + _parrotVolume.setBounds(Rect(17, 40, 147, 55)); + _parrotVolume.setSlidingBounds(Rect(35, 45, 127, 51)); + _parrotVolume.setThumbSize(Point(25, 15)); + _parrotVolume.translate(Point(415, 376)); + + _parrotVolume.setOrientation(ORIENTATION_HORIZONTAL); + _parrotVolume.setBounds(Rect(17, 60, 147, 75)); + _parrotVolume.setSlidingBounds(Rect(35, 65, 127, 71)); + _parrotVolume.setThumbSize(Point(25, 15)); + _parrotVolume.translate(Point(415, 376)); + + _element.setBounds(Rect(0, 0, 165, 77)); + _element.translate(Point(415, 376)); + + Rect rect(0, 0, 88, 16); + rect.translate(320, 376); + _textMasterVolume.setBounds(rect); + _textMasterVolume.resize(3); + _textMasterVolume.setHasBorder(false); + _textMasterVolume.setText("Master volume"); + + rect.translate(0, 20); + _textMusicVolume.setBounds(rect); + _textMusicVolume.resize(3); + _textMusicVolume.setHasBorder(false); + _textMusicVolume.setText("Music volume"); + + rect.translate(0, 20); + _textParrotVolume.setBounds(rect); + _textParrotVolume.resize(3); + _textParrotVolume.setHasBorder(false); + _textParrotVolume.setText("Parrot volume"); + + rect.translate(0, 20); + _textSpeechVolume.setBounds(rect); + _textSpeechVolume.resize(3); + _textSpeechVolume.setHasBorder(false); + _textSpeechVolume.setText("Speech volume"); + + return true; +} + +bool CPetSound::reset() { + CPetControl *pet = getPetControl(); + if (pet) { + setName("PetSound", pet); + _element.reset("PetVolChannels", pet, MODE_UNSELECTED); + _musicVolume.reset("PetVolSlug"); + _masterVolume.reset("PetVolSlug"); + _parrotVolume.reset("PetVolSlug"); + _speechVolume.reset("PetVolSlug"); + + CPetSection *section = getPetSection(); + uint col = section->getColor(0); + _textMusicVolume.setLineColor(0, col); + _textMasterVolume.setLineColor(0, col); + _textParrotVolume.setLineColor(0, col); + _textSpeechVolume.setLineColor(0, col); + } + + return false; +} + +void CPetSound::draw2(CScreenManager *screenManager) { + _element.draw(screenManager); + + _musicVolume.draw(screenManager); + _masterVolume.draw(screenManager); + _parrotVolume.draw(screenManager); + _speechVolume.draw(screenManager); + + _textMusicVolume.draw(screenManager); + _textMasterVolume.draw(screenManager); + _textParrotVolume.draw(screenManager); + _textSpeechVolume.draw(screenManager); +} + +bool CPetSound::MouseButtonDownMsg(const Point &pt) { + if (_musicVolume.checkThumb(pt) || _masterVolume.checkThumb(pt) || + _speechVolume.checkThumb(pt)) + return true; + + if (_parrotVolume.checkThumb(pt)) { + CPetControl *pet = getPetControl(); + if (pet) + pet->playSound(2); + + return true; + } + + Rect rectLeft(0, 0, 10, 11); + Rect rectRight(0, 0, 10, 11); + rectLeft.translate(415, 379); + rectRight.translate(567, 378); + + CPetSlider *sliders[4] = { &_masterVolume, &_musicVolume, &_parrotVolume, &_speechVolume }; + for (int idx = 0; idx < 4; ++idx) { + CPetSlider *slider = sliders[idx]; + bool isLeft = rectLeft.contains(pt); + bool isRight = rectRight.contains(pt); + double offset; + + if (isLeft) { + slider->stepPosition(-1); + offset = slider->getOffsetPixels(); + } else if (isRight) { + slider->stepPosition(1); + offset = slider->getOffsetPixels(); + } + + if (isLeft || isRight) { + sliderChanged(offset, idx); + return true; + } + + // Move to next slider row + rectLeft.translate(0, 20); + rectRight.translate(0, 20); + } + + return false; +} + +void CPetSound::sliderChanged(double offset, int sliderNum) { + CPetControl *pet = getPetControl(); + if (!pet) + return; + + CGameManager *gameManager = pet->getGameManager(); + if (!gameManager) + return; + + QSoundManager &soundManager = gameManager->_sound._soundManager; + double percent = offset * 100.0; + + switch (sliderNum) { + case 0: + soundManager.setMasterPercent(percent); + break; + case 1: + soundManager.setMusicPercent(percent); + break; + case 2: + soundManager.setParrotPercent(percent); + break; + case 3: + soundManager.setSpeechPercent(percent); + break; + default: + break; + } +} + +bool CPetSound::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (_musicVolume.resetThumbFocus()) { + _draggingSlider = &_musicVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 0; + return true; + } else if (_masterVolume.resetThumbFocus()) { + _draggingSlider = &_masterVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 1; + return true; + } else if (_parrotVolume.resetThumbFocus()) { + _draggingSlider = &_parrotVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 2; + return true; + } else if (_speechVolume.resetThumbFocus()) { + _draggingSlider = &_speechVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 3; + return true; + } + + _draggingSlider = nullptr; + return false; +} + +bool CPetSound::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + if (!_draggingSlider) + return false; + + if (_draggingSlider->MouseDragMoveMsg(msg->_mousePos)) { + double offset = _draggingSlider->getOffsetPixels(); + sliderChanged(offset, _draggingSliderNum); + getPetControl()->makeDirty(); + return true; + } + + return false; +} + +bool CPetSound::MouseDragEndMsg(CMouseDragEndMsg *msg) { + if (!_draggingSlider) + return false; + + _draggingSlider->MouseDragEndMsg(msg->_mousePos); + getOwner()->endDragging(); + + return false; +} + +bool CPetSound::MouseButtonUpMsg(const Point &pt) { + int sliderNum = 0; + CPetSlider *slider = nullptr; + + if (_musicVolume.MouseButtonUpMsg(pt)) { + sliderNum = 0; + slider = &_musicVolume; + } else if (_masterVolume.MouseButtonUpMsg(pt)) { + sliderNum = 1; + slider = &_masterVolume; + } else if (_parrotVolume.MouseButtonUpMsg(pt)) { + sliderNum = 2; + slider = &_parrotVolume; + } else if (_speechVolume.MouseButtonUpMsg(pt)) { + sliderNum = 3; + slider = &_speechVolume; + } else { + return false; + } + + double offset = slider->getOffsetPixels(); + sliderChanged(offset, sliderNum); + return true; +} + +void CPetSound::getTooltip(CPetText *text) { + text->setText("Change the volume settings."); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_sound.h b/engines/titanic/pet_control/pet_sound.h new file mode 100644 index 0000000000..c4b663ad44 --- /dev/null +++ b/engines/titanic/pet_control/pet_sound.h @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_SOUND_H +#define TITANIC_PET_SOUND_H + +#include "titanic/pet_control/pet_glyphs.h" +#include "titanic/pet_control/pet_gfx_element.h" +#include "titanic/pet_control/pet_text.h" +#include "titanic/pet_control/pet_slider.h" + +namespace Titanic { + +class CPetRealLife; + +class CPetSound : public CPetGlyph { +private: + CPetGfxElement _element; + CPetSlider _masterVolume; + CPetSlider _musicVolume; + CPetSlider _parrotVolume; + CPetSlider _speechVolume; + CPetText _textMasterVolume; + CPetText _textMusicVolume; + CPetText _textParrotVolume; + CPetText _textSpeechVolume; + CPetSlider *_draggingSlider; + int _draggingSliderNum; +private: + /** + * Called when a slider has changed + */ + void sliderChanged(double offset, int sliderNum); +public: + CPetSound(); + + /** + * Setup the glyph + */ + virtual bool setup(CPetControl *petControl, CPetGlyphs *owner); + + /** + * Reset the glyph + */ + virtual bool reset(); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + /** + * Called for mouse button down messages + */ + virtual bool MouseButtonDownMsg(const Point &pt); + + /** + * Called when mouse drag starts + */ + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg); + + /** + * Called during mouse drags + */ + virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + + /** + * Called when mouse drag ends + */ + virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_SOUND_H */ diff --git a/engines/titanic/pet_control/pet_starfield.cpp b/engines/titanic/pet_control/pet_starfield.cpp new file mode 100644 index 0000000000..34d696e09c --- /dev/null +++ b/engines/titanic/pet_control/pet_starfield.cpp @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_starfield.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/messages/pet_messages.h" +#include "titanic/star_control/star_control.h" + +namespace Titanic { + +CPetStarfield::CPetStarfield() : _field18C(0), _photoOn(true), + _hasReference(false), _rect1(22, 352, 598, 478) { + _btnOffsets[0] = _btnOffsets[1] = _btnOffsets[2] = 0; +} + +bool CPetStarfield::setup(CPetControl *petControl) { + if (petControl && setupControl(petControl)) + return reset(); + return false; +} + +bool CPetStarfield::reset() { + if (_petControl) { + _imgStarfield.setup(MODE_UNSELECTED, "3PetStarField", _petControl); + _imgPhoto.setup(MODE_UNSELECTED, "HomePhotoOnOff", _petControl); + _btnSetDest.setup(MODE_UNSELECTED, "3PetSetDestin", _petControl); + _btnSetDest.setup(MODE_SELECTED, "3PetSetDestin1", _petControl); + _imgStarCtrl.setup(MODE_UNSELECTED, "3PetStarCtrl", _petControl); + + _leds[0].setup(MODE_UNSELECTED, "LEDOff1", _petControl); + _leds[1].setup(MODE_UNSELECTED, "LEDOn1", _petControl); + _leds[2].setup(MODE_UNSELECTED, "LEDOff2", _petControl); + _leds[3].setup(MODE_UNSELECTED, "LEDOn2", _petControl); + _leds[4].setup(MODE_UNSELECTED, "LEDOff3", _petControl); + _leds[5].setup(MODE_UNSELECTED, "LEDOn3", _petControl); + + uint col = getColor(0); + _text.setColor(col); + _text.setLineColor(0, col); + } + + return true; +} + +void CPetStarfield::draw(CScreenManager *screenManager) { + _petControl->drawSquares(screenManager, 2); + + _imgStarfield.draw(screenManager); + if (_photoOn) { + _imgPhoto.draw(screenManager); + } else { + _imgStarCtrl.draw(screenManager); + } + + _btnSetDest.draw(screenManager); + drawButton(_btnOffsets[0], 0, screenManager); + drawButton(_btnOffsets[1], 2, screenManager); + drawButton(_btnOffsets[2], 4, screenManager); + _text.draw(screenManager); +} + +bool CPetStarfield::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_petControl->_remoteTarget) + return false; + + if (_imgStarfield.MouseButtonDownMsg(msg->_mousePos)) { + CPETHelmetOnOffMsg helmetMsg; + helmetMsg.execute(_petControl->_remoteTarget); + } else if (_imgPhoto.MouseButtonDownMsg(msg->_mousePos)) { + if (_hasReference) { + _photoOn = !_photoOn; + CPETPhotoOnOffMsg photoMsg; + photoMsg.execute(_petControl->_remoteTarget); + } else { + _petControl->displayMessage("Please supply Galactic reference material."); + } + } else if (!_btnSetDest.MouseButtonDownMsg(msg->_mousePos)) { + return elementsMouseDown(msg); + } + + return true; +} + +bool CPetStarfield::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!_petControl->_remoteTarget || !_btnSetDest.MouseButtonUpMsg(msg->_mousePos)) + return false; + + if (_petControl) { + CStarControl *starControl = _petControl->getStarControl(); + + if (starControl && starControl->canSetStarDestination()) { + CPETSetStarDestinationMsg starfieldMsg; + starfieldMsg.execute(_petControl->_remoteTarget); + starControl->starDestinationSet(); + } + } + + return true; +} + +bool CPetStarfield::isValid(CPetControl *petControl) { + return setupControl(petControl); +} + +void CPetStarfield::load(SimpleFile *file, int param) { + if (!param) { + _photoOn = file->readNumber(); + _hasReference = file->readNumber(); + } +} + +void CPetStarfield::postLoad() { + reset(); +} + +void CPetStarfield::save(SimpleFile *file, int indent) { + file->writeNumberLine(_photoOn, indent); + file->writeNumberLine(_hasReference, indent); +} + +bool CPetStarfield::setupControl(CPetControl *petControl) { + if (petControl) { + _petControl = petControl; + + Rect r(0, 0, 64, 64); + r.translate(_rect1.left, _rect1.top); + + _imgStarfield.setBounds(r); + _imgStarfield.translate(15, 23); + _imgPhoto.setBounds(r); + _imgPhoto.translate(85, 23); + _imgStarCtrl.setBounds(r); + _imgStarCtrl.translate(85, 23); + + r = Rect(0, 0, 34, 34); + r.translate(468, 396); + _leds[0].setBounds(r); + _leds[1].setBounds(r); + + r.translate(36, 0); + _leds[2].setBounds(r); + _leds[3].setBounds(r); + + r.translate(36, 0); + _leds[4].setBounds(r); + _leds[5].setBounds(r); + + r = Rect(0, 0, 157, 51); + r.translate(224, 33); + r.translate(20, 350); + _btnSetDest.setBounds(r); + + r = Rect(0, 0, 580, 15); + r.translate(32, 445); + _text.setBounds(r); + _text.setHasBorder(false); + } + + return true; +} + +void CPetStarfield::drawButton(int offset, int index, CScreenManager *screenManager) { + if (_field18C < 4 && (offset / 3) == 1) + --offset; + if (offset == 2) + offset = 1; + + _leds[index + offset].draw(screenManager); +} + +void CPetStarfield::setButtons(int val1, int val2) { + _btnOffsets[0] = 0; + _btnOffsets[1] = 0; + _btnOffsets[2] = 0; + + if (val1 >= 0) + _btnOffsets[0] = 2; + if (val1 >= 1) + _btnOffsets[1] = 2; + if (val1 >= 2) + _btnOffsets[2] = 2; + + if (val2) { + if (val1 == -1) + _btnOffsets[0] = 1; + if (val1 == 0) + _btnOffsets[1] = 1; + if (val1 == 1) + _btnOffsets[2] = 1; + } + + _field18C = (_field18C + 1) % 8; +} + +void CPetStarfield::makePetDirty() { + _petControl->makeDirty(); +} + +bool CPetStarfield::elementsMouseDown(CMouseButtonDownMsg *msg) { + if (elementMouseButton(0, msg, _leds[0].getBounds())) + return true; + if (elementMouseButton(1, msg, _leds[2].getBounds())) + return true; + if (elementMouseButton(2, msg, _leds[4].getBounds())) + return true; + + return false; +} + +bool CPetStarfield::elementMouseButton(int index, CMouseButtonDownMsg *msg, const Rect &rect) { + if (!rect.contains(msg->_mousePos)) + return false; + + switch (_btnOffsets[index]) { + case 1: + if (_petControl->_remoteTarget) { + CPETStarFieldLockMsg lockMsg(1); + lockMsg.execute(_petControl->_remoteTarget); + } + break; + + case 2: + if (index < 2 && _btnOffsets[index] >= 2) { + if (_petControl->_remoteTarget) { + CPETStarFieldLockMsg lockMsg(1); + lockMsg.execute(_petControl->_remoteTarget); + } + } + break; + + default: + break; + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_starfield.h b/engines/titanic/pet_control/pet_starfield.h new file mode 100644 index 0000000000..9550e0acf9 --- /dev/null +++ b/engines/titanic/pet_control/pet_starfield.h @@ -0,0 +1,125 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_STARFIELD_H +#define TITANIC_PET_STARFIELD_H + +#include "titanic/pet_control/pet_section.h" +#include "titanic/pet_control/pet_text.h" +#include "titanic/pet_control/pet_gfx_element.h" + +namespace Titanic { + +class CPetStarfield : public CPetSection { +private: + CPetGfxElement _imgStarfield; + CPetGfxElement _imgPhoto; + CPetGfxElement _imgStarCtrl; + CPetGfxElement _btnSetDest; + int _btnOffsets[3]; + CPetGfxElement _leds[6]; + Rect _rect1; + int _field18C; + CPetText _text; + bool _photoOn; + bool _hasReference; +private: + /** + * Setup the control + */ + bool setupControl(CPetControl *petControl); + + /** + * Draw a button + */ + void drawButton(int offset, int index, CScreenManager *screenManager); + + /** + * Mouse down handling for Nav elements + */ + bool elementsMouseDown(CMouseButtonDownMsg *msg); + + bool elementMouseButton(int index, CMouseButtonDownMsg *msg, const Rect &rect); +public: + CPetStarfield(); + + /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Reset the section + */ + virtual bool reset(); + + /** + * Draw the section + */ + virtual void draw(CScreenManager *screenManager); + + /** + * Following are handlers for the various messages that the PET can + * pass onto the currently active section/area + */ + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + + /** + * Returns true if the object is in a valid state + */ + virtual bool isValid(CPetControl *petControl); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param); + + /** + * Called after a game has been loaded + */ + virtual void postLoad(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Sets the offsets for each of the buttons + */ + void setButtons(int val1, int val2); + + /** + * Sets whether the player has the galactic reference material + */ + void setHasReference(bool hasRef) { _hasReference = hasRef; } + + /** + * Make the PET as dirty, requiring a redraw + */ + void makePetDirty(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_STARFIELD_H */ diff --git a/engines/titanic/pet_control/pet_text.cpp b/engines/titanic/pet_control/pet_text.cpp new file mode 100644 index 0000000000..6813095626 --- /dev/null +++ b/engines/titanic/pet_control/pet_text.cpp @@ -0,0 +1,478 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software(0), you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation(0), either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY(0), without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program(0), if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/pet_control/pet_text.h" + +namespace Titanic { + +CPetText::CPetText(uint count) : + _stringsMerged(false), _maxCharsPerLine(-1), _lineCount(0), + _linesStart(-1), _field3C(0), _field40(0), _field44(0), + _backR(0xff), _backG(0xff), _backB(0xff), + _textR(0), _textG(0), _textB(200), + _fontNumber(0), _field64(0), _field68(0), _field6C(0), + _hasBorder(true), _scrollTop(0), _textCursor(nullptr), _field7C(0) { + setupArrays(count); +} + +void CPetText::setupArrays(int count) { + freeArrays(); + if (count < 10 || count > 60) + count = 10; + _array.resize(count); +} + +void CPetText::freeArrays() { + _array.clear(); +} + +void CPetText::setup() { + for (int idx = 0; idx < (int)_array.size(); ++idx) { + _array[idx]._line.clear(); + setLineColor(idx, _textR, _textG, _textB); + _array[idx]._string3.clear(); + } + + _lineCount = 0; + _stringsMerged = false; +} + +void CPetText::setLineColor(uint lineNum, uint col) { + setLineColor(lineNum, col & 0xff, (col >> 16) & 0xff, (col >> 8) & 0xff); +} + +void CPetText::setLineColor(uint lineNum, byte r, byte g, byte b) { + char buffer[6]; + if (!r) + r = 1; + if (!g) + g = 1; + if (!b) + b = 1; + + buffer[0] = TEXTCMD_SET_COLOR; + buffer[1] = r; + buffer[2] = g; + buffer[3] = b; + buffer[4] = TEXTCMD_SET_COLOR; + buffer[5] = '\0'; + _array[lineNum]._rgb = buffer; + + _stringsMerged = false; +} + +void CPetText::load(SimpleFile *file, int param) { + if (!param) { + uint numLines = file->readNumber(); + uint charsPerLine = file->readNumber(); + uint count = file->readNumber(); + _bounds = file->readRect(); + _field3C = file->readNumber(); + _field40 = file->readNumber(); + _field44 = file->readNumber(); + _backR = file->readNumber(); + _backG = file->readNumber(); + _backB = file->readNumber(); + _textR = file->readNumber(); + _textG = file->readNumber(); + _textB = file->readNumber(); + _hasBorder = file->readNumber() != 0; + _scrollTop = file->readNumber(); + + resize(numLines); + setMaxCharsPerLine(charsPerLine); + + assert(_array.size() >= count); + for (uint idx = 0; idx < count; ++idx) { + _array[idx]._line = file->readString(); + _array[idx]._rgb = file->readString(); + _array[idx]._string3 = file->readString(); + } + } +} + +void CPetText::save(SimpleFile *file, int indent) { + int numLines = _lineCount + 1; + + file->writeNumberLine(_array.size(), indent); + file->writeNumberLine(_maxCharsPerLine, indent); + file->writeNumberLine(numLines, indent); + + file->writeRect(_bounds, indent); + file->writeNumberLine(_field3C, indent); + file->writeNumberLine(_field40, indent); + file->writeNumberLine(_field44, indent); + file->writeNumberLine(_backR, indent); + file->writeNumberLine(_backG, indent); + file->writeNumberLine(_backB, indent); + file->writeNumberLine(_textR, indent); + file->writeNumberLine(_textG, indent); + file->writeNumberLine(_textB, indent); + file->writeNumberLine(_hasBorder, indent); + file->writeNumberLine(_scrollTop, indent); + + for (int idx = 0; idx < numLines; ++idx) { + file->writeQuotedLine(_array[idx]._line, indent); + file->writeQuotedLine(_array[idx]._rgb, indent); + file->writeQuotedLine(_array[idx]._string3, indent); + } +} + +void CPetText::draw(CScreenManager *screenManager) { + Rect tempRect = _bounds; + + if (_hasBorder) { + // Create border effect + // Top edge + tempRect.bottom = tempRect.top + 1; + screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB); + + // Bottom edge + tempRect.top = _bounds.bottom - 1; + tempRect.bottom = _bounds.bottom; + screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB); + + // Left edge + tempRect = _bounds; + tempRect.right = tempRect.left + 1; + screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB); + + // Right edge + tempRect = _bounds; + tempRect.left = tempRect.right - 1; + screenManager->fillRect(SURFACE_BACKBUFFER, &tempRect, _backR, _backG, _backB); + } + + getTextHeight(screenManager); + + tempRect = _bounds; + tempRect.grow(-2); + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + + screenManager->writeString(SURFACE_BACKBUFFER, tempRect, _scrollTop, _lines, _textCursor); + + screenManager->setFontNumber(oldFontNumber); +} + +void CPetText::mergeStrings() { + if (!_stringsMerged) { + _lines.clear(); + + for (int idx = 0; idx <= _lineCount; ++idx) { + CString line = _array[idx]._rgb + _array[idx]._string3 + + _array[idx]._line + "\n"; + _lines += line; + } + + _stringsMerged = true; + } +} + +void CPetText::resize(uint count) { + if (!count || _array.size() == count) + return; + _array.clear(); + _array.resize(count); +} + +CString CPetText::getText() const { + CString result = ""; + for (int idx = 0; idx <= _lineCount; ++idx) + result += _array[idx]._line; + + return result; +} + +void CPetText::setText(const CString &str) { + setup(); + appendText(str); +} + +void CPetText::appendText(const CString &str) { + int lineSize = _array[_lineCount]._line.size(); + int strSize = str.size(); + + if (_maxCharsPerLine == -1) { + // No limit on horizontal characters, so append string to current line + _array[_lineCount]._line += str; + } else if ((lineSize + strSize) <= _maxCharsPerLine) { + // New string fits into line, so add it on + _array[_lineCount]._line += str; + } else { + // Only add part of the str up to the maximum allowed limit for line + _array[_lineCount]._line += str.left(_maxCharsPerLine - lineSize); + } + + updateStr3(_lineCount); + _stringsMerged = false; +} + +void CPetText::setColor(uint col) { + _textR = col & 0xff; + _textG = (col >> 8) & 0xff; + _textB = (col >> 16) & 0xff; +} + +void CPetText::setColor(byte r, byte g, byte b) { + _textR = r; + _textG = g; + _textB = b; +} + +void CPetText::remapColors(uint count, uint *srcColors, uint *destColors) { + if (_lineCount >= 0) { + for (int lineNum = 0; lineNum <= _lineCount; ++lineNum) { + // Get the rgb values + uint r = _array[lineNum]._rgb[1]; + uint g = _array[lineNum]._rgb[2]; + uint b = _array[lineNum]._rgb[3]; + uint color = r | (g << 8) | (b << 16); + + for (uint index = 0; index < count; ++index) { + if (color == srcColors[index]) { + // Found a match, so replace the color + setLineColor(lineNum, destColors[lineNum]); + break; + } + } + } + } + + _stringsMerged = false; +} + +void CPetText::setMaxCharsPerLine(int maxChars) { + if (maxChars >= -1 && maxChars < 257) + _maxCharsPerLine = maxChars; +} + +void CPetText::updateStr3(int lineNum) { + if (_field64 > 0 && _field68 > 0) { + char line[5]; + line[0] = line[3] = TEXTCMD_NPC; + line[1] = _field64; + line[2] = _field68; + line[4] = '\0'; + _array[lineNum]._string3 = CString(line); + + _stringsMerged = false; + _field64 = _field68 = 0; + } +} + +int CPetText::getTextWidth(CScreenManager *screenManager) { + mergeStrings(); + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + int textWidth = screenManager->stringWidth(_lines); + screenManager->setFontNumber(oldFontNumber); + + return textWidth; +} + +int CPetText::getTextHeight(CScreenManager *screenManager) { + mergeStrings(); + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + int textHeight = screenManager->getTextBounds(_lines, _bounds.width()); + screenManager->setFontNumber(oldFontNumber); + + return textHeight; +} + +void CPetText::deleteLastChar() { + if (!_array[_lineCount]._line.empty()) { + _array[_lineCount]._line.deleteLastChar(); + _stringsMerged = false; + } +} + +void CPetText::setNPC(int val1, int npcId) { + _field64 = val1; + _field68 = npcId; +} + +void CPetText::scrollUp(CScreenManager *screenManager) { + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + _scrollTop -= screenManager->getFontHeight(); + constrainScrollUp(screenManager); + screenManager->setFontNumber(oldFontNumber); +} + +void CPetText::scrollDown(CScreenManager *screenManager) { + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + _scrollTop += screenManager->getFontHeight(); + constrainScrollDown(screenManager); + screenManager->setFontNumber(oldFontNumber); +} + +void CPetText::scrollUpPage(CScreenManager *screenManager) { + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + _scrollTop -= getPageHeight(screenManager); + constrainScrollUp(screenManager); + screenManager->setFontNumber(oldFontNumber); +} + +void CPetText::scrollDownPage(CScreenManager *screenManager) { + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + _scrollTop += getPageHeight(screenManager); + constrainScrollDown(screenManager); + screenManager->setFontNumber(oldFontNumber); +} + +void CPetText::scrollToTop(CScreenManager *screenManager) { + _scrollTop = 0; +} + +void CPetText::scrollToBottom(CScreenManager *screenManager) { + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + _scrollTop = getTextHeight(screenManager); + constrainScrollDown(screenManager); + screenManager->setFontNumber(oldFontNumber); +} + +void CPetText::constrainScrollUp(CScreenManager *screenManager) { + if (_scrollTop < 0) + _scrollTop = 0; +} + +void CPetText::constrainScrollDown(CScreenManager *screenManager) { + // Figure out the maximum scroll amount allowed + int maxScroll = getTextHeight(screenManager) - _bounds.height() - 4; + if (maxScroll < 0) + maxScroll = 0; + + if (_scrollTop > maxScroll) + _scrollTop = maxScroll; +} + +int CPetText::getPageHeight(CScreenManager *screenManager) { + int textHeight = _bounds.height(); + int oldFontNumber = screenManager->setFontNumber(_fontNumber); + int fontHeight = screenManager->getFontHeight(); + screenManager->setFontNumber(oldFontNumber); + + if (fontHeight) { + int lines = textHeight / fontHeight; + if (lines > 1) + --lines; + return lines * fontHeight; + } else { + return 0; + } +} + +void CPetText::addLine(const CString &str) { + addLine(str, _textR, _textG, _textB); +} + +void CPetText::addLine(const CString &str, uint color) { + addLine(str, color & 0xff, (color >> 8) & 0xff, + (color >> 16) & 0xff); +} + +void CPetText::addLine(const CString &str, byte r, byte g, byte b) { + if (_lineCount == ((int)_array.size() - 1)) { + // Lines array is full + if (_array.size() > 1) { + // Delete the oldest line, and add a new entry at the end + _array.remove_at(0); + _array.resize(_array.size() + 1); + } + + --_lineCount; + } + + setLineColor(_lineCount, r, g, b); + appendText(str); + ++_lineCount; +} + +bool CPetText::handleKey(char c) { + switch (c) { + case (char)Common::KEYCODE_BACKSPACE: + deleteLastChar(); + break; + + case (char)Common::KEYCODE_RETURN: + return true; + + default: + if ((byte)c >= 32 && (byte)c <= 127) + appendText(CString(c, 1)); + break; + } + + return false; +} + +void CPetText::showCursor(int mode) { + CScreenManager *screenManager = CScreenManager::setCurrent(); + _textCursor = screenManager->_textCursor; + if (_textCursor) { + _textCursor->setPos(Point(0, 0)); + _textCursor->setSize(Point(2, 10)); + _textCursor->setColor(0, 0, 0); + _textCursor->setBlinkRate(300); + _textCursor->setMode(mode); + _textCursor->setBounds(_bounds); + _textCursor->show(); + } +} + +void CPetText::hideCursor() { + if (_textCursor) { + _textCursor->setMode(-1); + _textCursor->hide(); + _textCursor = nullptr; + } +} + +int CPetText::getNPCNum(uint npcId, uint startIndex) { + if (!_stringsMerged) { + mergeStrings(); + if (!_stringsMerged) + return -1; + } + + uint size = _lines.size(); + if (startIndex < 5 || startIndex >= size) + return -1; + + // Loop through string + for (const char *strP = _lines.c_str(); size >= 5; ++strP, --size) { + if (*strP == 26) { + byte id = *(strP - 2); + if (id == npcId) + return *(strP - 1); + } else if (*strP == 27) { + strP += 4; + } + } + + return - 1; +} + +void CPetText::setFontNumber(int fontNumber) { + if (fontNumber >= 0 && fontNumber <= 2) + _fontNumber = fontNumber; +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_text.h b/engines/titanic/pet_control/pet_text.h new file mode 100644 index 0000000000..f5d4235690 --- /dev/null +++ b/engines/titanic/pet_control/pet_text.h @@ -0,0 +1,270 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PET_TEXT_H +#define TITANIC_PET_TEXT_H + +#include "common/keyboard.h" +#include "titanic/support/simple_file.h" +#include "titanic/support/screen_manager.h" +#include "titanic/support/text_cursor.h" + +namespace Titanic { + +class CPetText { + struct ArrayEntry { + CString _line; + CString _rgb; + CString _string3; + }; +private: + Common::Array<ArrayEntry> _array; + CString _lines; + bool _stringsMerged; + Rect _bounds; + int _maxCharsPerLine; + int _lineCount; + int _linesStart; + int _field3C; + int _field40; + int _field44; + int _backR; + int _backG; + int _backB; + int _textR; + int _textG; + int _textB; + int _fontNumber; + int _field64; + int _field68; + int _field6C; + bool _hasBorder; + int _scrollTop; + CTextCursor *_textCursor; + int _field7C; +private: + void setupArrays(int count); + + void freeArrays(); + + /** + * Merges the strings in the strings array + */ + void mergeStrings(); + + /** + * Append text to the current text line + */ + void appendText(const CString &str); + + void updateStr3(int lineNum); + + /** + * Ensures the Y scrolling for the text is in the valid range + */ + void constrainScrollUp(CScreenManager *screenManager); + + /** + * Ensures the Y scrolling for the text is in the valid range + */ + void constrainScrollDown(CScreenManager *screenManager); + + /** + * Get the page height for paging up and down + */ + int getPageHeight(CScreenManager *screenManager); +public: + CPetText(uint count = 10); + + /** + * Set up the control + */ + void setup(); + + /** + * Load the data for the control + */ + void load(SimpleFile *file, int param); + + /** + * Save the data for the control + */ + void save(SimpleFile *file, int indent); + + /** + * Set the bounds for the control + */ + void setBounds(const Rect &bounds) { _bounds = bounds; } + + /** + * Sets the flag for whether to draw a frame border around the control + */ + void setHasBorder(bool val) { _hasBorder = val; } + + /** + * Draw the control + */ + void draw(CScreenManager *screenManager); + + void resize(uint count); + + /** + * Returns the text from all the lines as a single string + */ + CString getText() const; + + /** + * Set the text + */ + void setText(const CString &str); + + /** + * Set text color + */ + void setColor(uint col); + + /** + * Set text color + */ + void setColor(byte r, byte g, byte b); + + /** + * Set the color for a line + */ + void setLineColor(uint lineNum, byte r, byte g, byte b); + + /** + * Set the color for a line + */ + void setLineColor(uint lineNum, uint col); + + /** + * Sets the maximum number of characters per line + */ + void setMaxCharsPerLine(int maxChars); + + /** + * Delete the last character from the last line + */ + void deleteLastChar(); + + void setNPC(int val1, int npcId); + + /** + * Get the index into _lines where on-screen text starts + */ + int getLinesStart() const { return _linesStart; } + + /** + * Scroll the text up + */ + void scrollUp(CScreenManager *screenManager); + + /** + * Scroll the text down + */ + void scrollDown(CScreenManager *screenManager); + + /** + * Scroll the text up one page + */ + void scrollUpPage(CScreenManager *screenManager); + + /** + * Scroll the text down one page + */ + void scrollDownPage(CScreenManager *screenManager); + + /** + * Scroll to the top of the text + */ + void scrollToTop(CScreenManager *screenManager); + + /** + * Scroll to the bottom of the text + */ + void scrollToBottom(CScreenManager *screenManager); + + /** + * Add a line to the text + */ + void addLine(const CString &str); + + /** + * Add a line to the text + */ + void addLine(const CString &str, uint color); + + /** + * Add a line to the text + */ + void addLine(const CString &str, byte r, byte g, byte b); + + /** + * Handles character processing to add or remove characters to + * the current text line + * @returns True if the Enter key was pressed + */ + bool handleKey(char c); + + /** + * Attaches the current system cursor to the text control, + * and give it suitable defaults + */ + void showCursor(int mode); + + /** + * Removes the cursor attached to the text + */ + void hideCursor(); + + /** + * Get an NPC Number embedded within on-screen text. + * Used by the PET log to encode which NPC spoke + */ + int getNPCNum(uint npcId, uint startIndex); + + /** + * Replaces any occurances of line colors that appear in the + * first list with the entry at the same index in the dest list + */ + void remapColors(uint count, uint *srcColors, uint *destColors); + + /** + * Set the font number to use + */ + void setFontNumber(int fontNumber); + + /** + * Get the width of the text + */ + int getTextWidth(CScreenManager *screenManager); + + /** + * Get the required height to draw the text + */ + int getTextHeight(CScreenManager *screenManager); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_TEXT_H */ diff --git a/engines/titanic/room_flags.cpp b/engines/titanic/room_flags.cpp new file mode 100644 index 0000000000..4b3aeb424e --- /dev/null +++ b/engines/titanic/room_flags.cpp @@ -0,0 +1,527 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/room_flags.h" +#include "titanic/titanic.h" + +namespace Titanic { + +#define ELEVATOR_SHIFT 18 +#define ELEVATOR_MASK 3 +#define PASSENGER_CLASS_SHIFT 16 +#define PASSENGER_CLASS_MASK 3 +#define FLOOR_SHIFT 8 +#define FLOOR_MASK 0xFF +#define ROOM_SHIFT 1 +#define ROOM_MASK 0x7F + +struct TransportFlagsEntry { + const char *const _roomName; + uint _roomFlags; +}; +struct SuccUBusFlagsEntry { + const char *const _roomName; + uint _roomFlags; + uint _succubusNum; +}; + +#define TRANSPORT_ROOMS_SIZE 6 +const TransportFlagsEntry TRANSPORT_ROOMS[TRANSPORT_ROOMS_SIZE] = { + { "TopOfWell", 0xDF4D1 }, + { "Pellerator", 0xC95E9 }, + { "Dome", 0xAD171 }, + { "Lift", 0x96E45 }, + { "SGTLeisure", 0x5D3AD }, + { "ServiceElevator", 0x68797 } +}; + +#define SUCCUBUS_ROOMS_SIZE 17 +const SuccUBusFlagsEntry SUCCUBUS_ROOMS[SUCCUBUS_ROOMS_SIZE] = { + { "ParrotLobby", 0x1D0D9, 3 }, + { "SculptureChamber", 0x465FB, 2 }, + { "Bar", 0x0B3D97, 2 }, + { "EmbLobby", 0x0CC971, 3 }, + { "MoonEmbLobby", 0x0CC971, 3 }, + { "MusicRoom", 0x0F34DB, 2 }, + { "MusicRoomLobby", 0x0F34DB, 2 }, + { "Titania", 0x8A397, 3 }, + { "BottomOfWell", 0x59FAD, 3 }, + { "Arboretum", 0x4D6AF, 1 }, + { "PromenadeDeck", 0x79C45, 2 }, + { "1stClassRestaurant", 0x896B9, 1 }, + { "CreatorsChamber", 0x2F86D, 2 }, + { "CreatorsChamberOn", 0x2F86D, 2 }, + { "BilgeRoom", 0x3D94B, 3 }, + { "BilgeRoomWith", 0x3D94B, 3 }, + { "Bridge", 0x39FCB, 3 } +}; + +int CRoomFlags::getConditionally() const { + if (getRoomArea() != 5 || getRoomCategory() != 5) + return _data; + else + return 5; +} + +bool CRoomFlags::isTransportRoom() const { + for (int idx = 0; idx < TRANSPORT_ROOMS_SIZE; ++idx) { + if (TRANSPORT_ROOMS[idx]._roomFlags == _data) + return true; + } + + return false; +} + +int CRoomFlags::getRoomCategory() const { + if (getRoomNum() == 0) + return false; + + CRoomFlags tempFlags = _data; + tempFlags.setRoomBits(1); + return tempFlags.getRoomArea() != 5; +} + +int CRoomFlags::getRoomArea() const { + if (isSuccUBusRoomFlags()) + return 4; + + if (!getBit0()) { + uint v3 = getFloorNum(); + if (v3 <= 38) { + uint v4 = getRoomNum(); + if (v4 <= 18) { + uint v6 = getElevatorNum(); + + if (v6 >= 1 && v6 <= 4) { + uint v7 = getPassengerClassNum() - 1; + if (v7) { + uint v8 = v7 - 1; + if (v8) { + if (v8 == 1 && is28To38(v3) && (v6 & 1) && v4 >= 1) + return 3; + } else if (is20To27(v3)) { + if (v6 & 1) { + if (v4 >= 1 && v4 <= 3) + return 2; + } else if (v4 >= 1 && v4 <= 4) { + return 2; + } + } + } else if (is2To19(v3) && v4 >= 1 && v4 <= 3) { + return 1; + } + } + } + } + } + + return 5; +} + +CString CRoomFlags::getRoomDesc() const { + switch (getRoomArea()) { + case 1: + case 2: + case 3: { + CString result = getPassengerClassDesc(); + result += ", "; + result += getFloorDesc(); + result += ", "; + result += getElevatorDesc(); + result += ", "; + result += getRoomDesc(); + return result; + } + + case 4: + if (isTransportRoom()) { + switch (_data) { + case 0x68797: + return "The Service Elevator"; + case 0x5D3AD: + return "The Super Galactic Leisure Lounge"; + case 0x96E45: + return "The Elevator"; + case 0xAD171: + return "The Dome"; + case 0xC95E9: + return "The Pellerator"; + case 0xDF4D1: + return "The Top of the Well"; + default: + break; + } + } + + if (getRoomCategory() == 0) { + return "Nowhere you're likely to want to go."; + } else { + CString result = getPassengerClassDesc(); + result += ", "; + result += getFloorDesc(); + return result; + } + break; + + case 5: + switch (_data) { + case 0x1D0D9: + return "The Parrot Lobby"; + case 0x2F86D: + return "The Creators' Chamber"; + case 0x39FCB: + return "The Bridge"; + case 0x3D94B: + return "The Bilge Room"; + case 0x465FB: + return "The Sculpture Chamber"; + case 0x4D6AF: + return "The Arboretum"; + case 0x59FAD: + return "The Bottom of the Well"; + case 0x79C45: + return "The Promenade Deck"; + case 0x896B9: + return "The 1st class restaurant"; + case 0x8A397: + return "Titania's Room"; + case 0xB3D97: + return "The Bar"; + case 0xCC971: + return "The Embarkation Lobby"; + case 0xF34DB: + return "The Music Room"; + default: + break; + } + return "Unknown Room"; + + default: + break; + } + + return "Unknown Room"; +} + +void CRoomFlags::setElevatorBits(uint val) { + _data &= ~(ELEVATOR_MASK << ELEVATOR_SHIFT); + _data |= (val & ELEVATOR_MASK) << ELEVATOR_SHIFT; +} + +uint CRoomFlags::getElevatorBits() const { + return (_data >> ELEVATOR_SHIFT) & ELEVATOR_MASK; +} + +void CRoomFlags::setPassengerClassBits(uint val) { + _data &= ~(PASSENGER_CLASS_MASK << PASSENGER_CLASS_SHIFT); + _data |= (val & PASSENGER_CLASS_MASK) << PASSENGER_CLASS_SHIFT; +} + +uint CRoomFlags::getPassengerClassBits() const { + return (_data >> PASSENGER_CLASS_SHIFT) & PASSENGER_CLASS_MASK; +} + +CString CRoomFlags::getPassengerClassDesc() const { + int classNum = getPassengerClassNum(); + + switch (classNum) { + case 1: + return "1st class"; + case 2: + return "2nd class"; + case 3: + return "SGT class"; + default: + return "no class"; + } +} + +void CRoomFlags::setFloorBits(uint val) { + _data &= ~(FLOOR_MASK << FLOOR_SHIFT); + _data |= (val & FLOOR_MASK) << FLOOR_SHIFT; +} + +uint CRoomFlags::getFloorBits() const { + return (_data >> FLOOR_SHIFT) & FLOOR_MASK; +} + +uint CRoomFlags::decodeFloorBits(uint bits) const { + int base = 0; + int offset = bits & 0xF; + + switch ((bits >> 4) & 0xF) { + case 1: + case 2: + case 3: + base = 40; + break; + case 4: + base = 10; + break; + case 5: + base = 20; + break; + case 6: + base = 30; + break; + default: + break; + } + + return offset >= 10 ? 0 : base + offset; +} + +void CRoomFlags::setFloorNum(uint floorNum) { + uint base = 0; + + switch (floorNum / 10) { + case 0: + base = 0x90; + break; + case 1: + base = 0xD0; + case 2: + base = 0xE0; + case 3: + base = 0xF0; + break; + default: + break; + } + + setFloorBits(base | (floorNum % 10)); +} + +uint CRoomFlags::getFloorNum() const { + return decodeFloorBits(getFloorBits()); +} + +void CRoomFlags::setRoomBits(uint roomBits) { + _data &= ~(ROOM_MASK << ROOM_SHIFT); + _data |= (roomBits & ROOM_MASK) << ROOM_SHIFT; +} + +uint CRoomFlags::getRoomBits() const { + return (_data >> ROOM_SHIFT) & ROOM_MASK; +} + +bool CRoomFlags::isSuccUBusRoomFlags() const { + for (int idx = 0; idx < SUCCUBUS_ROOMS_SIZE; ++idx) { + if (SUCCUBUS_ROOMS[idx]._roomFlags == _data) + return true; + } + + return false; +} + +bool CRoomFlags::getBit0() const { + return _data & 1; +} + +uint CRoomFlags::getSpecialRoomFlags(const CString &roomName) { + for (int idx = 0; idx < SUCCUBUS_ROOMS_SIZE; ++idx) { + if (!roomName.compareTo(SUCCUBUS_ROOMS[idx]._roomName)) + return SUCCUBUS_ROOMS[idx]._roomFlags; + } + + for (int idx = 0; idx < TRANSPORT_ROOMS_SIZE; ++idx) { + if (!roomName.compareTo(TRANSPORT_ROOMS[idx]._roomName)) + return TRANSPORT_ROOMS[idx]._roomFlags; + } + + return 0; +} + +uint CRoomFlags::getSuccUBusNum(const CString &roomName) const { + for (int idx = 0; idx < SUCCUBUS_ROOMS_SIZE; ++idx) { + if (!roomName.compareTo(SUCCUBUS_ROOMS[idx]._roomName)) + return SUCCUBUS_ROOMS[idx]._succubusNum; + } + + return 0; +} + +CString CRoomFlags::getSuccUBusRoomName() const { + for (int idx = 0; idx < SUCCUBUS_ROOMS_SIZE; ++idx) { + if (SUCCUBUS_ROOMS[idx]._roomFlags == _data) + return SUCCUBUS_ROOMS[idx]._roomName; + } + + return CString(); +} + +void CRoomFlags::changeLocation(int action) { + uint floorNum = getFloorNum(); + uint roomNum = getRoomNum(); + uint elevatorNum = getElevatorNum(); + uint classNum = getPassengerClassNum(); + uint v10, v11, v12, v13; + + switch (classNum) { + case 1: + v10 = 2; + v11 = 19; + v12 = 1; + v13 = 3; + break; + + case 2: + v10 = 20; + v11 = 27; + v12 = 1; + v13 = (elevatorNum & 1) ? 3 : 4; + break; + + case 3: + v10 = 28; + v11 = 38; + v12 = 1; + v13 = 18; + break; + + default: + v10 = 0; + v11 = 0; + v12 = 0; + v13 = 0; + break; + } + + // Perform action to change room or floor + switch (action) { + case 1: + if (--roomNum < v12) + roomNum = v12; + break; + + case 2: + if (++roomNum > v13) + roomNum = v13; + break; + + case 3: + if (--floorNum < v10) + floorNum = v10; + break; + + case 4: + if (++floorNum > v11) + floorNum = v11; + } + + // Set new floor and room + setFloorNum(floorNum); + setRoomBits(roomNum); +} + +bool CRoomFlags::compareClassElevator(uint flags1, uint flags2) { + CRoomFlags f1(flags1); + CRoomFlags f2(flags2); + + if (f1.getFloorNum() != f2.getFloorNum()) + return false; + + uint elev1 = f1.getElevatorNum(); + uint elev2 = f2.getElevatorNum(); + uint class1 = f1.getPassengerClassNum(); + uint class2 = f2.getPassengerClassNum(); + + if (class1 > 0 && class1 < 3) { + if (elev1 == 2) + elev1 = 1; + else if (elev1 == 4) + elev1 = 3; + } + if (class2 > 0 && class2 < 3) { + if (elev2 == 2) + elev2 = 1; + else if (elev2 == 4) + elev2 = 3; + } + + return elev1 == elev2; +} + +bool CRoomFlags::compareLocation(uint flags1, uint flags2) { + CRoomFlags f1(flags1); + CRoomFlags f2(flags2); + + return f1.getElevatorNum() == f2.getElevatorBits() && + f1.getFloorNum() == f2.getFloorNum() && + f1.getRoomNum() == f2.getRoomNum(); +} + +bool CRoomFlags::isTitania(uint flags1, uint flags2) { + return flags2 == 0x8A397; +} + +void CRoomFlags::setRandomLocation(int classNum, bool flag) { + uint minRoom, elevNum, maxRoom, maxFloor, minFloor; + + do { + switch (classNum) { + case 1: + minFloor = 2; + maxFloor = 19; + minRoom = 1; + maxRoom = 3; + elevNum = g_vm->getRandomNumber(flag ? 2 : 3); + break; + + case 2: + minFloor = 20; + maxFloor = 27; + elevNum = g_vm->getRandomNumber(flag ? 2 : 3); + minRoom = 1; + maxRoom = ((elevNum - 1) & 1) ? 3 : 4; + break; + + case 3: + minRoom = 1; + minFloor = 28; + maxFloor = 38; + maxRoom = 18; + elevNum = g_vm->getRandomNumber(1); + if (elevNum == 1) + elevNum = 2; + break; + + default: + return; + } + + uint floorNum = minFloor + g_vm->getRandomNumber(maxFloor - minFloor); + uint roomNum = minRoom + g_vm->getRandomNumber(maxRoom - minRoom); + setElevatorBits(elevNum); + setRoomBits(roomNum); + setFloorNum(floorNum); + } while (_data == 0x59706); +} + +int CRoomFlags::whatPassengerClass(int floorNum) { + if (is2To19(floorNum)) + return 1; + + return is20To27(floorNum) ? 2 : 3; +} + +} // End of namespace Titanic diff --git a/engines/titanic/room_flags.h b/engines/titanic/room_flags.h new file mode 100644 index 0000000000..f0f90f80d1 --- /dev/null +++ b/engines/titanic/room_flags.h @@ -0,0 +1,230 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ROOM_FLAGS_H +#define TITANIC_ROOM_FLAGS_H + +#include "titanic/support/string.h" + +namespace Titanic { + +class CRoomFlags { +private: + uint _data; +private: + int getConditionally() const; + + /** + * Returns true if the current flags appear in the + * list of transport rooms + */ + bool isTransportRoom() const; + + int getRoomCategory() const; + + int getRoomArea() const; + + /** + * Set the bits for the elevator number + */ + void setElevatorBits(uint val); + + /** + * Set the bits for the floor number + */ + void setFloorBits(uint val); + + /** + * Translates bits for floor into a floor number + */ + uint decodeFloorBits(uint bits) const; + + static bool is2To19(uint v) { return v >= 2 && v <= 19; } + static bool is20To27(uint v) { return v >= 20 && v <= 27; } + static bool is28To38(uint v) { return v >= 28 && v <= 38; } +public: + /** + * Compares the current flags against the specified flags + * for a matching elevator, floor, and room + */ + static bool compareLocation(uint flags1, uint flags2); + + /** + * Compares two room flags together + */ + static bool compareClassElevator(uint flags1, uint flags2); + + /** + * Returns true if the current flags is for Titania's room + */ + static bool isTitania(uint flags1, uint flags2); +public: + CRoomFlags() : _data(0) {} + CRoomFlags(uint data) : _data(data) {} + operator uint() { return _data; } + + /** + * Set the flags value + */ + void set(uint data) { _data = data; } + + /** + * Get the flags value + */ + uint get() const { return _data; } + + /** + * Gets the special flags for a transport or succubus room + */ + static uint getSpecialRoomFlags(const CString &roomName); + + /** + * Returns true if the current flags are in the succubus list + */ + bool isSuccUBusRoomFlags() const; + + /** + * Get a description for the room + */ + CString getRoomDesc() const; + + /** + * Get the bits for the elevator number + */ + uint getElevatorBits() const; + + /** + * Set the elevator number + */ + void setElevatorNum(uint val) { setElevatorBits(val - 1); } + + /** + * Get the elevator number + */ + uint getElevatorNum() const { return getElevatorBits() + 1; } + + /** + * Get a description for the elevator number + */ + CString getElevatorDesc() const { + return CString::format("Elevator %d", getElevatorNum()); + } + + /** + * Gets the bits for the passenger class + */ + uint getPassengerClassBits() const; + + /** + * Set the bits for the passenger class + */ + void setPassengerClassBits(uint val); + + /** + * Gets the passenger class number + */ + uint getPassengerClassNum() const { return getPassengerClassBits(); } + + /** + * Get a description for the passenger class + */ + CString getPassengerClassDesc() const; + + /** + * Gets the bits for the floor number + */ + uint getFloorBits() const; + + /** + * Sets the floor number + */ + void setFloorNum(uint floorNum); + + /** + * Gets the floor number + */ + uint getFloorNum() const; + + /** + * Get a description for the floor number + */ + CString getFloorDesc() const { + return CString::format("Floor %d", getFloorNum()); + } + + /** + * Sets the bits for the room number + */ + void setRoomBits(uint roomBits); + + /** + * Gets the bits for the room number + */ + uint getRoomBits() const; + + /** + * Gets the room number + */ + uint getRoomNum() const { return getRoomBits(); } + + /** + * Gets a string for the room number + */ + CString getRoomNumDesc() const { + return CString::format("Room %d", getRoomNum()); + } + + bool getBit0() const; + + /** + * Change the passenger class + */ + void changeLocation(int action); + + /** + * Sets a random destination in the flags + */ + void setRandomLocation(int classNum, bool flag); + + /** + * Gets the succubus number associated with a given room + */ + uint getSuccUBusNum(const CString &roomName) const; + + /** + * Gets the succubus room name associated with the current room flags + */ + CString getSuccUBusRoomName() const; + + /** + * Returns what passenger class a particular floor number belongs to + */ + static int whatPassengerClass(int floorNum); + + bool not5() const { return getConditionally() != 5; } + + bool is59706() const { return _data == 0x59706; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ROOM_FLAGS_H */ diff --git a/engines/titanic/sound/auto_music_player.cpp b/engines/titanic/sound/auto_music_player.cpp new file mode 100644 index 0000000000..ce20c33765 --- /dev/null +++ b/engines/titanic/sound/auto_music_player.cpp @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/auto_music_player.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAutoMusicPlayer, CAutoMusicPlayerBase) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + +CAutoMusicPlayer::CAutoMusicPlayer() : CAutoMusicPlayerBase() { +} + +void CAutoMusicPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_leaveRoomSound, indent); + + CAutoMusicPlayerBase::save(file, indent); +} + +void CAutoMusicPlayer::load(SimpleFile *file) { + file->readNumber(); + _leaveRoomSound = file->readString(); + + CAutoMusicPlayerBase::load(file); +} + +bool CAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) { + if (!_isRepeated) { + CRoomItem *room = findRoom(); + if (msg->_newRoom == room) + addTimer(2000); + } + + return true; +} + +bool CAutoMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) { + if (_isRepeated) { + CRoomItem *room = findRoom(); + if (msg->_oldRoom == room) { + CChangeMusicMsg changeMsg; + changeMsg._flags = 1; + changeMsg.execute(this); + } + } + + if (!_leaveRoomSound.empty()) + playSound(_leaveRoomSound); + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/auto_music_player.h b/engines/titanic/sound/auto_music_player.h new file mode 100644 index 0000000000..722aa9cd7f --- /dev/null +++ b/engines/titanic/sound/auto_music_player.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AUTO_MUSIC_PLAYER_H +#define TITANIC_AUTO_MUSIC_PLAYER_H + +#include "titanic/sound/auto_music_player_base.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CAutoMusicPlayer : public CAutoMusicPlayerBase { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); +private: + CString _leaveRoomSound; +public: + CLASSDEF; + CAutoMusicPlayer(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AUTO_MUSIC_PLAYER_H */ diff --git a/engines/titanic/sound/auto_music_player_base.cpp b/engines/titanic/sound/auto_music_player_base.cpp new file mode 100644 index 0000000000..ad8b848c03 --- /dev/null +++ b/engines/titanic/sound/auto_music_player_base.cpp @@ -0,0 +1,101 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/auto_music_player_base.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAutoMusicPlayerBase, CGameObject) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(LoadSuccessMsg) + ON_MESSAGE(ChangeMusicMsg) +END_MESSAGE_MAP() + +CAutoMusicPlayerBase::CAutoMusicPlayerBase() : CGameObject(), + _initialMute(true), _isRepeated(false), _volumeMode(-1), _transition(1) { +} +void CAutoMusicPlayerBase::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_filename, indent); + file->writeNumberLine(_initialMute, indent); + file->writeNumberLine(_isRepeated, indent); + file->writeNumberLine(_volumeMode, indent); + file->writeNumberLine(_transition, indent); + + CGameObject::save(file, indent); +} + +void CAutoMusicPlayerBase::load(SimpleFile *file) { + file->readNumber(); + _filename = file->readString(); + _initialMute = file->readNumber(); + _isRepeated = file->readNumber(); + _volumeMode = file->readNumber(); + _transition = file->readNumber(); + + CGameObject::load(file); +} + +bool CAutoMusicPlayerBase::StatusChangeMsg(CStatusChangeMsg *msg) { + return true; +} + +bool CAutoMusicPlayerBase::TimerMsg(CTimerMsg *msg) { + CChangeMusicMsg musicMsg; + musicMsg._flags = 2; + musicMsg.execute(this); + + return true; +} + +bool CAutoMusicPlayerBase::LoadSuccessMsg(CLoadSuccessMsg *msg) { + if (_isRepeated) + playGlobalSound(_filename, _volumeMode, _initialMute, true, 0); + + return true; +} + +bool CAutoMusicPlayerBase::ChangeMusicMsg(CChangeMusicMsg *msg) { + if (_isRepeated && msg->_flags == 1) { + _isRepeated = false; + stopGlobalSound(_transition, -1); + } + + if (!msg->_filename.empty()) { + _filename = msg->_filename; + + if (_isRepeated) { + stopGlobalSound(_transition, -1); + playGlobalSound(_filename, _volumeMode, _initialMute, true, 0); + } + } + + if (_isRepeated && msg->_flags == 2) { + _isRepeated = true; + playGlobalSound(_filename, _volumeMode, _initialMute, true, 0); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/auto_music_player_base.h b/engines/titanic/sound/auto_music_player_base.h new file mode 100644 index 0000000000..0623258887 --- /dev/null +++ b/engines/titanic/sound/auto_music_player_base.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AUTO_MUSIC_PLAYER_BASE_H +#define TITANIC_AUTO_MUSIC_PLAYER_BASE_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CAutoMusicPlayerBase : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); + bool ChangeMusicMsg(CChangeMusicMsg *msg); +protected: + CString _filename; + bool _initialMute; + bool _isRepeated; + int _volumeMode; + int _transition; +public: + CLASSDEF; + CAutoMusicPlayerBase(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AUTO_MUSIC_PLAYER_BASE_H */ diff --git a/engines/titanic/sound/auto_sound_player.cpp b/engines/titanic/sound/auto_sound_player.cpp new file mode 100644 index 0000000000..8267d65037 --- /dev/null +++ b/engines/titanic/sound/auto_sound_player.cpp @@ -0,0 +1,134 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/auto_sound_player.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAutoSoundPlayer, CGameObject) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(SignalObject) + ON_MESSAGE(SetVolumeMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + +CAutoSoundPlayer::CAutoSoundPlayer() : CGameObject(), + _fieldBC(0), _volume(70), _fieldD0(0), _repeated(false), _soundHandle(-1), + _stopSeconds(0), _startSeconds(-1), _active(false), _fieldE8(0) { +} + +void CAutoSoundPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_fieldBC, indent); + file->writeQuotedLine(_filename, indent); + file->writeNumberLine(_volume, indent); + file->writeNumberLine(_fieldD0, indent); + file->writeNumberLine(_repeated, indent); + file->writeNumberLine(_soundHandle, indent); + file->writeNumberLine(_stopSeconds, indent); + file->writeNumberLine(_startSeconds, indent); + file->writeNumberLine(_active, indent); + file->writeNumberLine(_fieldE8, indent); + + CGameObject::save(file, indent); +} + +void CAutoSoundPlayer::load(SimpleFile *file) { + file->readNumber(); + _fieldBC = file->readNumber(); + _filename = file->readString(); + _volume = file->readNumber(); + _fieldD0 = file->readNumber(); + _repeated = file->readNumber(); + _soundHandle = file->readNumber(); + _stopSeconds = file->readNumber(); + _startSeconds = file->readNumber(); + _active = file->readNumber(); + _fieldE8 = file->readNumber(); + + CGameObject::load(file); +} + +bool CAutoSoundPlayer::TurnOn(CTurnOn *msg) { + if (_soundHandle == -1) { + CProximity prox; + prox._fieldC = _fieldD0; + prox._repeated = _repeated; + if (_fieldE8) + prox._positioningMode = POSMODE_VECTOR; + prox._channelVolume = (_startSeconds == -1) ? _volume : 0; + + _soundHandle = playSound(_filename, prox); + if (_startSeconds != -1) + setSoundVolume(_soundHandle, _volume, _startSeconds); + + _active = true; + } + + return true; +} + +bool CAutoSoundPlayer::TurnOff(CTurnOff *msg) { + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, _stopSeconds); + + _soundHandle = -1; + _active = false; + } + + return true; +} + +bool CAutoSoundPlayer::SignalObject(CSignalObject *msg) { + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, msg->_numValue); + + _soundHandle = -1; + _active = false; + } + + return true; +} + +bool CAutoSoundPlayer::SetVolumeMsg(CSetVolumeMsg *msg) { + if (_soundHandle != -1 && isSoundActive(_soundHandle)) + setSoundVolume(_soundHandle, msg->_volume, msg->_secondsTransition); + + return true; +} + +bool CAutoSoundPlayer::LoadSuccessMsg(CLoadSuccessMsg *msg) { + if (_active) { + _soundHandle = -1; + _active = false; + + CTurnOn onMsg; + onMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/auto_sound_player.h b/engines/titanic/sound/auto_sound_player.h new file mode 100644 index 0000000000..c8f1d3480e --- /dev/null +++ b/engines/titanic/sound/auto_sound_player.h @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AUTO_SOUND_PLAYER_H +#define TITANIC_AUTO_SOUND_PLAYER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CAutoSoundPlayer : public CGameObject { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool SignalObject(CSignalObject *msg); + bool SetVolumeMsg(CSetVolumeMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); +public: + int _fieldBC; + CString _filename; + int _volume; + int _fieldD0; + bool _repeated; + int _soundHandle; + int _stopSeconds; + int _startSeconds; + bool _active; + int _fieldE8; +public: + CLASSDEF; + CAutoSoundPlayer(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AUTO_SOUND_PLAYER_H */ diff --git a/engines/titanic/sound/auto_sound_player_adsr.cpp b/engines/titanic/sound/auto_sound_player_adsr.cpp new file mode 100644 index 0000000000..f9f045759b --- /dev/null +++ b/engines/titanic/sound/auto_sound_player_adsr.cpp @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/auto_sound_player_adsr.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CAutoSoundPlayerADSR, CAutoSoundPlayer) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) +END_MESSAGE_MAP() + +void CAutoSoundPlayerADSR::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_soundName1, indent); + file->writeQuotedLine(_soundName2, indent); + file->writeQuotedLine(_soundName3, indent); + CAutoSoundPlayer::save(file, indent); +} + +void CAutoSoundPlayerADSR::load(SimpleFile *file) { + file->readNumber(); + _soundName1 = file->readString(); + _soundName2 = file->readString(); + _soundName3 = file->readString(); + CAutoSoundPlayer::load(file); +} + +bool CAutoSoundPlayerADSR::TurnOn(CTurnOn *msg) { + if (_soundHandle == -1) { + if (!_soundName1.empty()) { + _soundHandle = playSound(_soundName1, _volume, _fieldD0); + + if (!_soundName2.empty()) + _soundHandle = queueSound(_soundName2, _soundHandle, _volume, _fieldD0); + + _soundHandle = queueSound(_filename, _soundHandle, _volume, _fieldD0); + _active = true; + } + } + + return true; +} + +bool CAutoSoundPlayerADSR::TurnOff(CTurnOff *msg) { + if (_soundHandle != -1) { + if (!_soundName3.empty()) + queueSound(_soundName3, _soundHandle, _volume, _fieldD0); + + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle); + + _soundHandle = -1; + _active = false; + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/auto_sound_player_adsr.h b/engines/titanic/sound/auto_sound_player_adsr.h new file mode 100644 index 0000000000..9f09636610 --- /dev/null +++ b/engines/titanic/sound/auto_sound_player_adsr.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AUTO_SOUND_PLAYER_ADSR_H +#define TITANIC_AUTO_SOUND_PLAYER_ADSR_H + +#include "titanic/sound/auto_sound_player.h" + +namespace Titanic { + +class CAutoSoundPlayerADSR : public CAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); +private: + CString _soundName1; + CString _soundName2; + CString _soundName3; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AUTO_SOUND_PLAYER_ADSR_H */ diff --git a/engines/titanic/sound/background_sound_maker.cpp b/engines/titanic/sound/background_sound_maker.cpp new file mode 100644 index 0000000000..58dde02518 --- /dev/null +++ b/engines/titanic/sound/background_sound_maker.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/background_sound_maker.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CBackgroundSoundMaker, CGameObject) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + +void CBackgroundSoundMaker::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + CGameObject::save(file, indent); +} + +void CBackgroundSoundMaker::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + CGameObject::load(file); +} + +bool CBackgroundSoundMaker::FrameMsg(CFrameMsg *msg) { + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/background_sound_maker.h b/engines/titanic/sound/background_sound_maker.h new file mode 100644 index 0000000000..94f3b792dc --- /dev/null +++ b/engines/titanic/sound/background_sound_maker.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BACKGROUND_SOUND_MAKER_H +#define TITANIC_BACKGROUND_SOUND_MAKER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CBackgroundSoundMaker : public CGameObject { + DECLARE_MESSAGE_MAP; + bool FrameMsg(CFrameMsg *msg); +public: + int _value; +public: + CLASSDEF; + CBackgroundSoundMaker() : CGameObject(), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BACKGROUND_SOUND_MAKER_H */ diff --git a/engines/titanic/sound/bird_song.cpp b/engines/titanic/sound/bird_song.cpp new file mode 100644 index 0000000000..53a25e2dbe --- /dev/null +++ b/engines/titanic/sound/bird_song.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/bird_song.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CBirdSong, CAutoSoundPlayer) + ON_MESSAGE(TurnOn) + ON_MESSAGE(SignalObject) +END_MESSAGE_MAP() + +void CBirdSong::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_flag, indent); + CRoomAutoSoundPlayer::save(file, indent); +} + +void CBirdSong::load(SimpleFile *file) { + file->readNumber(); + _flag = file->readNumber(); + CRoomAutoSoundPlayer::load(file); +} + +bool CBirdSong::TurnOn(CTurnOn *msg) { + if (!_flag) + CAutoSoundPlayer::TurnOn(msg); + return true; +} + +bool CBirdSong::SignalObject(CSignalObject *msg) { + _flag = true; + CAutoSoundPlayer::SignalObject(msg); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/bird_song.h b/engines/titanic/sound/bird_song.h new file mode 100644 index 0000000000..52af94b180 --- /dev/null +++ b/engines/titanic/sound/bird_song.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BIRD_SONG_H +#define TITANIC_BIRD_SONG_H + +#include "titanic/sound/room_auto_sound_player.h" + +namespace Titanic { + +class CBirdSong : public CRoomAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool SignalObject(CSignalObject *msg); +public: + bool _flag; +public: + CLASSDEF; + CBirdSong() : CRoomAutoSoundPlayer(), _flag(false) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BIRD_SONG_H */ diff --git a/engines/titanic/sound/dome_from_top_of_well.cpp b/engines/titanic/sound/dome_from_top_of_well.cpp new file mode 100644 index 0000000000..789d7fa4cb --- /dev/null +++ b/engines/titanic/sound/dome_from_top_of_well.cpp @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/dome_from_top_of_well.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CDomeFromTopOfWell, CViewAutoSoundPlayer); + +CDomeFromTopOfWell::CDomeFromTopOfWell() : CViewAutoSoundPlayer() { + _filename = "z#227.wav"; + _volume = 25; + _repeated = true; + _stopSeconds = 1; + _startSeconds = 1; +} + +void CDomeFromTopOfWell::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CViewAutoSoundPlayer::save(file, indent); +} + +void CDomeFromTopOfWell::load(SimpleFile *file) { + file->readNumber(); + CViewAutoSoundPlayer::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/dome_from_top_of_well.h b/engines/titanic/sound/dome_from_top_of_well.h new file mode 100644 index 0000000000..001f66a1a8 --- /dev/null +++ b/engines/titanic/sound/dome_from_top_of_well.h @@ -0,0 +1,49 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DOME_FROM_TOP_OF_WELL_H +#define TITANIC_DOME_FROM_TOP_OF_WELL_H + +#include "titanic/sound/view_auto_sound_player.h" + +namespace Titanic { + +class CDomeFromTopOfWell : public CViewAutoSoundPlayer { + DECLARE_MESSAGE_MAP; +public: + CLASSDEF; + CDomeFromTopOfWell(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DOME_FROM_TOP_OF_WELL_H */ diff --git a/engines/titanic/sound/enter_view_toggles_other_music.cpp b/engines/titanic/sound/enter_view_toggles_other_music.cpp new file mode 100644 index 0000000000..2f0091a0a3 --- /dev/null +++ b/engines/titanic/sound/enter_view_toggles_other_music.cpp @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/enter_view_toggles_other_music.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CEnterViewTogglesOtherMusic, CTriggerAutoMusicPlayer) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CEnterViewTogglesOtherMusic::CEnterViewTogglesOtherMusic() : + CTriggerAutoMusicPlayer(), _value(2) { +} + +void CEnterViewTogglesOtherMusic::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + + CTriggerAutoMusicPlayer::save(file, indent); +} + +void CEnterViewTogglesOtherMusic::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + + CTriggerAutoMusicPlayer::load(file); +} + +bool CEnterViewTogglesOtherMusic::EnterViewMsg(CEnterViewMsg *msg) { + CViewItem *view = findView(); + if (view == msg->_newView) { + CTriggerAutoMusicPlayerMsg triggerMsg; + triggerMsg._value = _value; + triggerMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/enter_view_toggles_other_music.h b/engines/titanic/sound/enter_view_toggles_other_music.h new file mode 100644 index 0000000000..a91b1e1933 --- /dev/null +++ b/engines/titanic/sound/enter_view_toggles_other_music.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ENTER_VIEW_TOGGLES_OTHER_MUSIC_H +#define TITANIC_ENTER_VIEW_TOGGLES_OTHER_MUSIC_H + +#include "titanic/sound/trigger_auto_music_player.h" + +namespace Titanic { + +class CEnterViewTogglesOtherMusic : public CTriggerAutoMusicPlayer { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); +protected: + int _value; +public: + CLASSDEF; + CEnterViewTogglesOtherMusic(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ENTER_VIEW_TOGGLES_OTHER_MUSIC_H */ diff --git a/engines/titanic/sound/gondolier_song.cpp b/engines/titanic/sound/gondolier_song.cpp new file mode 100644 index 0000000000..5c96718723 --- /dev/null +++ b/engines/titanic/sound/gondolier_song.cpp @@ -0,0 +1,94 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include "titanic/sound/gondolier_song.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CGondolierSong, CRoomAutoSoundPlayer) + ON_MESSAGE(TurnOn) + ON_MESSAGE(SignalObject) + ON_MESSAGE(SetVolumeMsg) + ON_MESSAGE(StatusChangeMsg) +END_MESSAGE_MAP() + +void CGondolierSong::save(SimpleFile *file, int indent) { + file->writeNumberLine(_enabled, indent); + file->writeNumberLine(_value, indent); + CRoomAutoSoundPlayer::save(file, indent); +} + +void CGondolierSong::load(SimpleFile *file) { + _enabled = file->readNumber(); + _value = file->readNumber(); + CRoomAutoSoundPlayer::load(file); +} + +bool CGondolierSong::TurnOn(CTurnOn *msg) { + if (_enabled) { + if (_soundHandle != -1) { + int volume = _value * _volume / 100; + + if (_startSeconds == -1) { + _soundHandle = playSound(_filename, volume, _fieldD0, _repeated); + } else { + _soundHandle = playSound(_filename, 0, _fieldD0, _repeated); + setSoundVolume(_soundHandle, _volume, _startSeconds); + } + + _active = true; + } + } + + return true; +} + +bool CGondolierSong::SignalObject(CSignalObject *msg) { + _enabled = false; + CAutoSoundPlayer::SignalObject(msg); + return true; +} + +bool CGondolierSong::SetVolumeMsg(CSetVolumeMsg *msg) { + if (_enabled) { + _volume = msg->_volume; + + if (_soundHandle != -1 && isSoundActive(_soundHandle)) { + int newVolume = _value * _volume / 100; + setSoundVolume(_soundHandle, newVolume, msg->_secondsTransition); + } + } + + return true; +} + +bool CGondolierSong::StatusChangeMsg(CStatusChangeMsg *msg) { + if (_enabled) { + _value = CLIP(msg->_newStatus, 0, 100); + CSetVolumeMsg volumeMsg(_volume, _stopSeconds); + volumeMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/gondolier_song.h b/engines/titanic/sound/gondolier_song.h new file mode 100644 index 0000000000..d586711de9 --- /dev/null +++ b/engines/titanic/sound/gondolier_song.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_GONDOLIER_SONG_H +#define TITANIC_GONDOLIER_SONG_H + +#include "titanic/sound/room_auto_sound_player.h" + +namespace Titanic { + +class CGondolierSong : public CRoomAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool SignalObject(CSignalObject *msg); + bool SetVolumeMsg(CSetVolumeMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); +public: + bool _enabled; + int _value; +public: + CLASSDEF; + CGondolierSong() : CRoomAutoSoundPlayer(), _enabled(true), _value(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_GONDOLIER_SONG_H */ diff --git a/engines/titanic/sound/music_handler.cpp b/engines/titanic/sound/music_handler.cpp new file mode 100644 index 0000000000..037c340f0b --- /dev/null +++ b/engines/titanic/sound/music_handler.cpp @@ -0,0 +1,80 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/music_handler.h" +#include "titanic/sound/sound_manager.h" +#include "titanic/core/project_item.h" + +namespace Titanic { + +CMusicHandler::CMusicHandler(CProjectItem *project, CSoundManager *soundManager) : + _project(project), _soundManager(soundManager), _stopWaves(false), + _soundHandle(-1), _waveFile(nullptr) { + Common::fill(&_musicWaves[0], &_musicWaves[4], (CMusicWave *)nullptr); +} + +CMusicHandler::~CMusicHandler() { + stop(); +} + +CMusicWave *CMusicHandler::createMusicWave(int waveIndex, int count) { + switch (waveIndex) { + case 0: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 2); + break; + case 1: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 3); + break; + case 2: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 0); + break; + case 3: + _musicWaves[waveIndex] = new CMusicWave(_project, _soundManager, 1); + break; + default: + return nullptr; + } + + _musicWaves[waveIndex]->setSize(count); + return _musicWaves[waveIndex]; +} + +bool CMusicHandler::isBusy() { + // TODO + return false; +} + +void CMusicHandler::stop() { + if (_waveFile) { + _soundManager->stopSound(_soundHandle); + delete _waveFile; + _waveFile = nullptr; + _soundHandle = -1; + } + + for (int idx = 0; idx < 4; ++idx) { + if (_stopWaves && _musicWaves[idx]) + _musicWaves[idx]->stop(); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/music_handler.h b/engines/titanic/sound/music_handler.h new file mode 100644 index 0000000000..17ffea965a --- /dev/null +++ b/engines/titanic/sound/music_handler.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_HANDLER_H +#define TITANIC_MUSIC_HANDLER_H + +#include "titanic/sound/music_wave.h" +#include "titanic/sound/wave_file.h" + +namespace Titanic { + +class CProjectItem; +class CSoundManager; + +class CMusicHandler { +private: + CProjectItem *_project; + CSoundManager *_soundManager; + CMusicWave *_musicWaves[4]; + bool _stopWaves; + CWaveFile *_waveFile; + int _soundHandle; +public: + CMusicHandler(CProjectItem *project, CSoundManager *soundManager); + ~CMusicHandler(); + + /** + * Creates a new music wave class instance, and assigns it to a slot + * in the music handler + * @param waveIndex Slot to save new instance in + * @param count Number of files the new instance will contain + */ + CMusicWave *createMusicWave(int waveIndex, int count); + + bool isBusy(); + + /** + * Flags whether the loaded music waves will be stopped when the + * music handler is stopped + */ + void setStopWaves(bool flag) { _stopWaves = flag; } + + /** + * Stop playing the music + */ + void stop(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_HANDLER_H */ diff --git a/engines/titanic/sound/music_player.cpp b/engines/titanic/sound/music_player.cpp new file mode 100644 index 0000000000..cd764c7f93 --- /dev/null +++ b/engines/titanic/sound/music_player.cpp @@ -0,0 +1,182 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/music_player.h" +#include "titanic/sound/music_room.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CMusicPlayer, CGameObject) + ON_MESSAGE(StartMusicMsg) + ON_MESSAGE(StopMusicMsg) + ON_MESSAGE(FrameMsg) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(CreateMusicPlayerMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + +void CMusicPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_isActive, indent); + file->writeQuotedLine(_stopTarget, indent); + file->writeNumberLine(_stopWaves, indent); + file->writeNumberLine(_musicId, indent); + + CGameObject::save(file, indent); +} + +void CMusicPlayer::load(SimpleFile *file) { + file->readNumber(); + _isActive = file->readNumber(); + _stopTarget = file->readString(); + _stopWaves = file->readNumber(); + _musicId = file->readNumber(); + + CGameObject::load(file); +} + +bool CMusicPlayer::StartMusicMsg(CStartMusicMsg *msg) { + if (msg->_musicPlayer == this) { + if (_isActive) { + CStopMusicMsg stopMusicMsg; + stopMusicMsg.execute(this); + } + + return false; + } + + if (!_isActive) { + lockMouse(); + + CCreateMusicPlayerMsg createMsg; + createMsg.execute(this); + CSetMusicControlsMsg controlsMsg; + controlsMsg.execute(this, nullptr, MSGFLAG_SCAN); + + getMusicRoom()->startMusic(_musicId); + _isActive = true; + } + + return true; +} + +bool CMusicPlayer::StopMusicMsg(CStopMusicMsg *msg) { + if (!_isActive) + // Player isn't playing, so ignore message + return false; + + // Stop the music + CMusicRoom *musicRoom = getMusicRoom(); + if (musicRoom) + musicRoom->stopMusic(); + _isActive = false; + + CMusicHasStoppedMsg stoppedMsg; + stoppedMsg.execute(_stopTarget, nullptr, MSGFLAG_SCAN); + return true; +} + +bool CMusicPlayer::FrameMsg(CFrameMsg *msg) { + if (_isActive && !CMusicRoom::_musicHandler->isBusy()) { + getMusicRoom()->stopMusic(); + _isActive = false; + + CMusicHasStoppedMsg stoppedMsg; + stoppedMsg.execute(_stopTarget); + } + + return true; +} + +bool CMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) { + addTimer(100); + return true; +} + +bool CMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) { + getMusicRoom()->destroyMusicHandler(); + return true; +} + +bool CMusicPlayer::CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg) { + if (CMusicRoom::_musicHandler) { + CMusicRoom::_musicHandler->setStopWaves(_stopWaves); + return true; + } + + CMusicHandler *musicHandler = getMusicRoom()->createMusicHandler(); + CMusicWave *wave; + + if (musicHandler) { + wave = musicHandler->createMusicWave(0, 3); + wave->load(0, "z#490.wav", 60); + wave->load(1, "z#488.wav", 62); + wave->load(2, "z#489.wav", 63); + + wave = musicHandler->createMusicWave(1, 5); + wave->load(0, "z#493.wav", 22); + wave->load(1, "z#495.wav", 29); + wave->load(2, "z#492.wav", 34); + wave->load(3, "z#494.wav", 41); + wave->load(4, "z#491.wav", 46); + + wave = musicHandler->createMusicWave(2, 5); + wave->load(0, "z#499.wav", 26); + wave->load(1, "z#497.wav", 34); + wave->load(2, "z#498.wav", 38); + wave->load(3, "z#496.wav", 46); + wave->load(4, "z#500.wav", 60); + + wave = musicHandler->createMusicWave(3, 7); + wave->load(0, "z#504.wav", 22); + wave->load(1, "z#507.wav", 29); + wave->load(2, "z#503.wav", 34); + wave->load(3, "z#506.wav", 41); + wave->load(4, "z#502.wav", 46); + wave->load(5, "z#505.wav", 53); + wave->load(6, "z#501.wav", 58); + + CMusicRoom::_musicHandler->setStopWaves(_stopWaves); + } + + return true; +} + +bool CMusicPlayer::TimerMsg(CTimerMsg *msg) { + CCreateMusicPlayerMsg playerMsg; + playerMsg.execute(this); + return true; +} + +bool CMusicPlayer::LoadSuccessMsg(CLoadSuccessMsg *msg) { + if (_isActive) { + CStopMusicMsg stopMsg; + stopMsg.execute(this); + CStartMusicMsg startMsg; + startMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/music_player.h b/engines/titanic/sound/music_player.h new file mode 100644 index 0000000000..7b82d4da00 --- /dev/null +++ b/engines/titanic/sound/music_player.h @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_PLAYER_H +#define TITANIC_MUSIC_PLAYER_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CMusicPlayer : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StartMusicMsg(CStartMusicMsg *msg); + bool StopMusicMsg(CStopMusicMsg *msg); + bool FrameMsg(CFrameMsg *msg); + bool EnterRoomMsg(CEnterRoomMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool CreateMusicPlayerMsg(CCreateMusicPlayerMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); +protected: + bool _isActive; + CString _stopTarget; + bool _stopWaves; + int _musicId; +public: + CLASSDEF; + CMusicPlayer() : CGameObject(), + _isActive(false), _stopWaves(false), _musicId(100) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_PLAYER_H */ diff --git a/engines/titanic/sound/music_room.cpp b/engines/titanic/sound/music_room.cpp new file mode 100644 index 0000000000..34217de184 --- /dev/null +++ b/engines/titanic/sound/music_room.cpp @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/sound/music_room.h" +#include "titanic/sound/sound.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CMusicHandler *CMusicRoom::_musicHandler; + +CMusicRoom::CMusicRoom(CGameManager *gameManager) : + _gameManager(gameManager) { + _sound = &_gameManager->_sound; + _items.resize(4); +} + +CMusicRoom::~CMusicRoom() { + destroyMusicHandler(); +} + +CMusicHandler *CMusicRoom::createMusicHandler() { + if (_musicHandler) + destroyMusicHandler(); + + _musicHandler = new CMusicHandler(_gameManager->_project, &_sound->_soundManager); + return _musicHandler; +} + +void CMusicRoom::destroyMusicHandler() { + delete _musicHandler; + _musicHandler = nullptr; +} + +void CMusicRoom::startMusic(int musicId) { + // TODO +} + +void CMusicRoom::stopMusic() { + if (_musicHandler) + _musicHandler->stop(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/music_room.h b/engines/titanic/sound/music_room.h new file mode 100644 index 0000000000..15363ef392 --- /dev/null +++ b/engines/titanic/sound/music_room.h @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_ROOM_H +#define TITANIC_MUSIC_ROOM_H + +#include "common/array.h" +#include "titanic/sound/music_handler.h" + +namespace Titanic { + +class CGameManager; +class CSound; + +class CMusicRoom { + struct Entry { + uint _val1; + uint _val2; + uint _val3; + uint _val4; + uint _val5; + + Entry() : _val1(0), _val2(0), _val3(0), _val4(0), _val5(0) {} + }; +private: + Common::Array<Entry> _items; +public: + static CMusicHandler *_musicHandler; +public: + CGameManager *_gameManager; + CSound *_sound; +public: + CMusicRoom(CGameManager *owner); + ~CMusicRoom(); + + /** + * Creates a music handler + */ + CMusicHandler *createMusicHandler(); + + /** + * Destroys and currently active music handler + */ + void destroyMusicHandler(); + + void setItem1(int index, int val) { _items[index]._val1 = val; } + void setItem2(int index, int val) { _items[index]._val2 = val; } + void setItem3(int index, int val) { _items[index]._val3 = val; } + void setItem4(int index, int val) { _items[index]._val4 = val; } + void setItem5(int index, int val) { _items[index]._val5 = val; } + + /** + * Start playing a given music number + */ + void startMusic(int musicId); + + /** + * Stop playing music + */ + void stopMusic(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_ROOM_H */ diff --git a/engines/titanic/sound/music_wave.cpp b/engines/titanic/sound/music_wave.cpp new file mode 100644 index 0000000000..6b5b187805 --- /dev/null +++ b/engines/titanic/sound/music_wave.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/music_wave.h" +#include "titanic/sound/sound_manager.h" +#include "titanic/core/project_item.h" + +namespace Titanic { + +CMusicWave::CMusicWave(CProjectItem *project, CSoundManager *soundManager, int index) : + _project(project), _soundManager(soundManager) { +} + +void CMusicWave::setSize(uint count) { + assert(_items.empty()); + _items.resize(count); +} + +void CMusicWave::load(int index, const CString &filename, int v3) { + assert(!_items[index]._waveFile); + _items[index]._waveFile = createWaveFile(filename); + _items[index]._value = v3; +} + +CWaveFile *CMusicWave::createWaveFile(const CString &name) { + if (name.empty()) + return nullptr; + return _soundManager->loadSound(name); +} + +void CMusicWave::stop() { + +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/music_wave.h b/engines/titanic/sound/music_wave.h new file mode 100644 index 0000000000..b240f4a856 --- /dev/null +++ b/engines/titanic/sound/music_wave.h @@ -0,0 +1,71 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MUSIC_WAVE_H +#define TITANIC_MUSIC_WAVE_H + +#include "common/array.h" +#include "titanic/support/string.h" + +namespace Titanic { + +class CProjectItem; +class CSoundManager; +class CWaveFile; + +class CMusicWave { + struct CMusicWaveFile { + CWaveFile *_waveFile; + int _value; + CMusicWaveFile() : _waveFile(nullptr), _value(0) {} + }; +private: + CProjectItem *_project; + CSoundManager *_soundManager; + Common::Array<CMusicWaveFile> _items; +private: + /** + * Loads the specified wave file, and returns a CWaveFile instance for it + */ + CWaveFile *createWaveFile(const CString &name); +public: + CMusicWave(CProjectItem *project, CSoundManager *soundManager, int index); + + /** + * Sets the maximum number of allowed files that be defined + */ + void setSize(uint count); + + /** + * Loads a new file into the list of available entries + */ + void load(int index, const CString &filename, int v3); + + /** + * Stops the music + */ + void stop(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MUSIC_WAVE_H */ diff --git a/engines/titanic/sound/node_auto_sound_player.cpp b/engines/titanic/sound/node_auto_sound_player.cpp new file mode 100644 index 0000000000..40b3d2ea39 --- /dev/null +++ b/engines/titanic/sound/node_auto_sound_player.cpp @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/node_auto_sound_player.h" +#include "titanic/sound/auto_music_player.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CNodeAutoSoundPlayer, CAutoSoundPlayer) + ON_MESSAGE(EnterNodeMsg) + ON_MESSAGE(LeaveNodeMsg) +END_MESSAGE_MAP() + +void CNodeAutoSoundPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_enabled, indent); + CAutoSoundPlayer::save(file, indent); +} + +void CNodeAutoSoundPlayer::load(SimpleFile *file) { + file->readNumber(); + _enabled = file->readNumber(); + CAutoSoundPlayer::load(file); +} + +bool CNodeAutoSoundPlayer::EnterNodeMsg(CEnterNodeMsg *msg) { + CNodeItem *node = findNode(); + CRoomItem *room = findRoom(); + + if (node == msg->_newNode) { + CTurnOn onMsg; + onMsg.execute(this); + + if (_enabled) { + CChangeMusicMsg changeMsg; + changeMsg._flags = 1; + changeMsg.execute(room, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + } + } + + return true; +} + +bool CNodeAutoSoundPlayer::LeaveNodeMsg(CLeaveNodeMsg *msg) { + CNodeItem *node = findNode(); + CRoomItem *room = findRoom(); + + if (node == msg->_oldNode) { + CTurnOff offMsg; + offMsg.execute(this); + + if (_enabled) { + CChangeMusicMsg changeMsg; + changeMsg._flags = 2; + changeMsg.execute(room, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + } + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/node_auto_sound_player.h b/engines/titanic/sound/node_auto_sound_player.h new file mode 100644 index 0000000000..f5bdc42c3c --- /dev/null +++ b/engines/titanic/sound/node_auto_sound_player.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_NODE_AUTO_SOUND_PLAYER_H +#define TITANIC_NODE_AUTO_SOUND_PLAYER_H + +#include "titanic/sound/auto_sound_player.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CNodeAutoSoundPlayer : public CAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool EnterNodeMsg(CEnterNodeMsg *msg); + bool LeaveNodeMsg(CLeaveNodeMsg *msg); +private: + bool _enabled; +public: + CLASSDEF; + CNodeAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(true) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NODE_AUTO_SOUND_PLAYER_H */ diff --git a/engines/titanic/sound/proximity.cpp b/engines/titanic/sound/proximity.cpp new file mode 100644 index 0000000000..7f4e6784f2 --- /dev/null +++ b/engines/titanic/sound/proximity.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/proximity.h" +#include "titanic/true_talk/tt_talker.h" + +namespace Titanic { + +CProximity::CProximity() : _field4(0), _channelVolume(100), _fieldC(0), + _priorSoundHandle(-1), _field14(0), _frequencyMultiplier(0.0), _field1C(1.875), + _repeated(false), _channel(10), _positioningMode(POSMODE_NONE), _azimuth(0.0), + _range(0.5), _elevation(0), _posX(0.0), _posY(0.0), _posZ(0.0), + _hasVelocity(false), _velocityX(0), _velocityY(0), _velocityZ(0), + _field54(0), _field58(0), _field5C(0), _freeSoundFlag(false), _endTalkerFn(nullptr), + _talker(nullptr), _field6C(0) { +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/proximity.h b/engines/titanic/sound/proximity.h new file mode 100644 index 0000000000..b728f22c26 --- /dev/null +++ b/engines/titanic/sound/proximity.h @@ -0,0 +1,71 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PROXIMITY_H +#define TITANIC_PROXIMITY_H + +#include "common/scummsys.h" + +namespace Titanic { + +enum PositioningMode { POSMODE_NONE = 0, POSMODE_POLAR = 1, POSMODE_VECTOR = 2 }; + +class TTtalker; + +typedef void (*CEndTalkerFn)(TTtalker *talker); + +class CProximity { +public: + int _field4; + int _channelVolume; + int _fieldC; + int _priorSoundHandle; + int _field14; + double _frequencyMultiplier; + double _field1C; + bool _repeated; + int _channel; + PositioningMode _positioningMode; + double _azimuth; + double _range; + double _elevation; + double _posX; + double _posY; + double _posZ; + bool _hasVelocity; + double _velocityX; + double _velocityY; + double _velocityZ; + int _field54; + int _field58; + int _field5C; + bool _freeSoundFlag; + CEndTalkerFn _endTalkerFn; + TTtalker *_talker; + int _field6C; +public: + CProximity(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PROXIMITY_H */ diff --git a/engines/titanic/sound/qmixer.cpp b/engines/titanic/sound/qmixer.cpp new file mode 100644 index 0000000000..145d142b2d --- /dev/null +++ b/engines/titanic/sound/qmixer.cpp @@ -0,0 +1,173 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/qmixer.h" + +namespace Titanic { + +QMixer::QMixer(Audio::Mixer *mixer) : _mixer(mixer) { +} + +bool QMixer::qsWaveMixInitEx(const QMIXCONFIG &config) { + assert(_channels.empty()); + assert(config.iChannels > 0 && config.iChannels < 256); + + _channels.resize(config.iChannels); + return true; +} + +void QMixer::qsWaveMixActivate(bool fActivate) { + // Not currently implemented in ScummVM +} + +int QMixer::qsWaveMixOpenChannel(int iChannel, QMixFlag mode) { + // Not currently implemented in ScummVM + return 0; +} + +int QMixer::qsWaveMixEnableChannel(int iChannel, uint flags, bool enabled) { + // Not currently implemented in ScummVM + return 0; +} + +void QMixer::qsWaveMixCloseSession() { + _mixer->stopAll(); + _channels.clear(); +} + +void QMixer::qsWaveMixFreeWave(Audio::SoundHandle &handle) { + _mixer->stopHandle(handle); +} + +void QMixer::qsWaveMixFlushChannel(int iChannel, uint flags) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetPanRate(int iChannel, uint flags, uint rate) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetVolume(int iChannel, uint flags, uint volume) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetSourcePosition(int iChannel, uint flags, const QSVECTOR &position) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetPolarPosition(int iChannel, uint flags, const QSPOLAR &position) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetListenerPosition(const QSVECTOR &position, uint flags) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetListenerOrientation(const QSVECTOR &direction, const QSVECTOR &up, uint flags) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetDistanceMapping(int iChannel, uint flags, const QMIX_DISTANCES &distances) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetFrequency(int iChannel, uint flags, uint frequency) { + // Not currently implemented in ScummVM +} + +void QMixer::qsWaveMixSetSourceVelocity(int iChannel, uint flags, const QSVECTOR &velocity) { + // Not currently implemented in ScummVM +} + +int QMixer::qsWaveMixPlayEx(int iChannel, uint flags, CWaveFile *waveFile, int loops, const QMIXPLAYPARAMS ¶ms) { + if (iChannel == -1) { + // Find a free channel + for (iChannel = 0; iChannel < (int)_channels.size(); ++iChannel) { + if (_channels[iChannel]._sounds.empty()) + break; + } + assert(iChannel != (int)_channels.size()); + } + + // If the new sound replaces current ones, then clear the channel + ChannelEntry &channel = _channels[iChannel]; + if (flags & QMIX_CLEARQUEUE) { + if (!channel._sounds.empty() && channel._sounds.front()._started) + _mixer->stopHandle(channel._sounds.front()._soundHandle); + + channel._sounds.clear(); + } + + // Add the sound to the channel + channel._sounds.push_back(SoundEntry(waveFile, params.callback, loops, params.dwUser)); + qsWaveMixPump(); + + return 0; +} + +bool QMixer::qsWaveMixIsChannelDone(int iChannel) const { + return _channels[iChannel]._sounds.empty(); +} + +void QMixer::qsWaveMixPump() { + // Iterate through each of the channels + for (uint iChannel = 0; iChannel < _channels.size(); ++iChannel) { + ChannelEntry &channel = _channels[iChannel]; + + // If the playing sound on the channel is finished, then call + // the callback registered for it, and remove it from the list + if (!channel._sounds.empty()) { + SoundEntry &sound = channel._sounds.front(); + if (sound._started && !_mixer->isSoundHandleActive(sound._soundHandle)) { + if (sound._loops == -1 || sound._loops-- > 0) { + // Need to loop the sound again + sound._waveFile->_stream->rewind(); + _mixer->playStream(sound._waveFile->_soundType, + &sound._soundHandle, sound._waveFile->_stream, + -1, 0xff, 0, DisposeAfterUse::NO); + } else { + // Sound is finished + if (sound._callback) + // Call the callback to signal end + sound._callback(iChannel, sound._waveFile, sound._userData); + + // Remove sound record from channel + channel._sounds.erase(channel._sounds.begin()); + } + } + } + + // If there's an unstarted sound at the front of a channel's + // sound list, then start it playing + if (!channel._sounds.empty()) { + SoundEntry &sound = channel._sounds.front(); + if (!sound._started) { + _mixer->playStream(sound._waveFile->_soundType, + &sound._soundHandle, sound._waveFile->_stream, + -1, 0xff, 0, DisposeAfterUse::NO); + sound._started = true; + } + } + } +} + +} // End of namespace Titanic z diff --git a/engines/titanic/sound/qmixer.h b/engines/titanic/sound/qmixer.h new file mode 100644 index 0000000000..4ba76a8969 --- /dev/null +++ b/engines/titanic/sound/qmixer.h @@ -0,0 +1,312 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * aint with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_QMIXER_H +#define TITANIC_QMIXER_H + +#include "audio/mixer.h" +#include "titanic/sound/wave_file.h" + +namespace Titanic { + +enum QMixFlag { + QMIX_OPENSINGLE = 0, // Open the single channel specified by iChannel + QMIX_OPENALL = 1, // Opens all the channels, iChannel ignored + QMIX_OPENCOUNT = 2, // Open iChannel Channels (eg. if iChannel = 4 will create channels 0-3) + QMIX_OPENAVAILABLE = 3, // Open the first unopened channel, and return channel number + + // Channel function flags + QMIX_ALL = 0x01, // apply to all channels + QMIX_NOREMIX = 0x02, // don't remix + QMIX_CONTROL_NOREMIX = 0x04, // don't remix + QMIX_USEONCE = 0x10 // settings are temporary +}; + +// qsWaveMixEnableChannel flags: if mode==0, use conventional, high-performance +// stereo mixer. Non-zero modes imply some form of additional processing. +enum QMixChannelFlag { + QMIX_CHANNEL_STEREO = 0x0000, // Perform stereo mixing + QMIX_CHANNEL_QSOUND = 0x0001, // Perform QSound localization (default) + QMIX_CHANNEL_DOPPLER = 0x0002, // Calculate velocity using position updates + QMIX_CHANNEL_RANGE = 0x0004, // Do range effects + QMIX_CHANNEL_ELEVATION = 0x0008, // Do elevation effects + QMIX_CHANNEL_NODOPPLERPITCH = 0x0010, // Disable Doppler pitch shift for this channel + QMIX_CHANNEL_PITCH_COPY = 0x0000, // Pitch shifting using copying (fastest) + QMIX_CHANNEL_PITCH_LINEAR = 0x0100, // Pitch shifting using linear interpolation (better but slower) + QMIX_CHANNEL_PITCH_SPLINE = 0x0200, // Pitch shifting using spline interpolation (better yet, but much slower) + QMIX_CHANNEL_PITCH_FILTER = 0x0300, // Pitch shifting using FIR filter (best, but slowest) + QMIX_CHANNEL_PITCH_MASK = 0x0700 // Bits reserved for pitch types +}; + +/** + * Options for dwFlags parameter in QSWaveMixPlayEx. + * + * Notes: The QMIX_USELRUCHANNEL flag has two roles. When QMIX_CLEARQUEUE is also set, + * the channel that has been playing the longest (least-recently-used) is cleared and + * the buffer played. When QMIX_QUEUEWAVE is set, the channel that will first finish + * playing will be selected and the buffer queued to play. Of course, if an unused + * channel is found, it will be selected instead. + * If QMIX_WAIT hasn't been specified, then the channel number will be returned + * in the iChannel field. + */ +enum QMixPlayFlag { + QMIX_QUEUEWAVE = 0x0000, // Queue on channel + QMIX_CLEARQUEUE = 0x0001, // Clear queue on channel + QMIX_USELRUCHANNEL = 0x0002, // See notes above + QMIX_HIGHPRIORITY = 0x0004, + QMIX_WAIT = 0x0008, // Queue to be played with other sounds + QMIX_IMMEDIATE = 0x0020, // Apply volume/pan changes without interpolation + + QMIX_PLAY_SETEVENT = 0x0100, // Calls SetEvent in the original library when done + QMIX_PLAY_PULSEEVENT = 0x0200, // Calls PulseEvent in the original library when done + QMIX_PLAY_NOTIFYSTOP = 0x0400 // Do callback even when stopping or flushing sound +}; + +/** + * Mixer configuration structure for qsWaveMixInitEx + */ +struct QMIXCONFIG { + uint32 dwSize; + uint32 dwFlags; + uint32 dwSamplingRate; // Sampling rate in Hz + void *lpIDirectSound; + const void *lpGuid; + int iChannels; // Number of channels + int iOutput; // if 0, uses best output device + int iLatency; // (in ms) if 0, uses default for output device + int iMath; // style of math + uint hwnd; + + QMIXCONFIG() : dwSize(40), dwFlags(0), dwSamplingRate(0), lpIDirectSound(nullptr), + lpGuid(nullptr), iChannels(0), iOutput(0), iLatency(0), iMath(0), hwnd(0) {} + QMIXCONFIG(uint32 rate, int channels, int latency) : dwSize(40), dwFlags(0), + dwSamplingRate(rate), iChannels(channels), iLatency(latency), + lpIDirectSound(nullptr), lpGuid(nullptr), iOutput(0), iMath(0), hwnd(0) {} +}; + +/** + * Vector positioning in metres + */ +struct QSVECTOR { + double x; + double y; + double z; + + QSVECTOR() : x(0.0), y(0.0), z(0.0) {} + QSVECTOR(double xp, double yp, double zp) : x(xp), y(yp), z(zp) {} +}; + +/** + * Polar positioning + */ +struct QSPOLAR { + double azimuth; // degrees + double range; // meters + double elevation; // degrees + + QSPOLAR() : azimuth(0.0), range(0.0), elevation(0.0) {} + QSPOLAR(double azimuth_, double range_, double elevation_) : + azimuth(azimuth_), range(range_), elevation(elevation_) {} +}; + +struct QMIX_DISTANCES { + int cbSize; // Structure size + double minDistance; // sounds are at full volume if closer than this + double maxDistance; // sounds are muted if further away than this + double scale; // relative amount to adjust rolloff by + + QMIX_DISTANCES() : cbSize(16), minDistance(0.0), maxDistance(0.0), scale(0.0) {} + QMIX_DISTANCES(double minDistance_, double maxDistance_, double scale_) : + cbSize(16), minDistance(minDistance_), maxDistance(maxDistance_), scale(scale_) {} +}; + +typedef void (*LPQMIXDONECALLBACK)(int iChannel, CWaveFile *lpWave, void *dwUser); + +struct QMIXPLAYPARAMS { + uint dwSize; // Size of the play structure + void *lpImage; // Additional preprocessed audio for high performance + uint hwndNotify; // if set, WOM_OPEN and WOM_DONE messages sent to that window + LPQMIXDONECALLBACK callback; // Callback function + void *dwUser; // User data accompanying callback + int lStart; + int lStartLoop; + int lEndLoop; + int lEnd; + const void *lpChannelParams; // initialize with these parameters + // Properties introduced by ScummVM + Audio::Mixer::SoundType _soundType; + + QMIXPLAYPARAMS() : dwSize(36), lpImage(nullptr), hwndNotify(0), callback(nullptr), + dwUser(nullptr), lStart(0), lStartLoop(0), lEndLoop(0), lEnd(0), + lpChannelParams(nullptr), _soundType(Audio::Mixer::kPlainSoundType) {} +}; + +/** + * This class represents an interface to the QMixer library developed by + * QSound Labs, Inc. Which itself is apparently based on Microsoft's + * WaveMix API. + * + * It does not currently have any actual code from the library, + * and instead remaps calls to ScummVM's existing mixer where possible. + * This means that advanced features of the QMixer library, like being + * able to set up both the player and sounds at different positions are + * currently ignored, and all sounds play at full volume. + */ +class QMixer { + struct SoundEntry { + bool _started; + CWaveFile *_waveFile; + Audio::SoundHandle _soundHandle; + LPQMIXDONECALLBACK _callback; + int _loops; + void *_userData; + SoundEntry() : _started(false), _waveFile(nullptr), _callback(nullptr), + _loops(0), _userData(nullptr) {} + + SoundEntry(CWaveFile *waveFile, LPQMIXDONECALLBACK callback, int loops, void *userData) : + _started(false), _waveFile(waveFile), _callback(callback), _loops(loops), _userData(userData) {} + }; + struct ChannelEntry { + Common::List<SoundEntry> _sounds; + }; +private: + Audio::Mixer *_mixer; + Common::Array<ChannelEntry> _channels; +public: + QMixer(Audio::Mixer *mixer); + virtual ~QMixer() {} + + /** + * Initializes the mixer + */ + bool qsWaveMixInitEx(const QMIXCONFIG &config); + + /** + * Activates the mixer + */ + void qsWaveMixActivate(bool fActivate); + + /** + * Opens channels in the mixer for access + */ + int qsWaveMixOpenChannel(int iChannel, QMixFlag mode); + + /** + * Enables a given channel + */ + int qsWaveMixEnableChannel(int iChannel, uint flags, bool enabled); + + /** + * Closes down the mixer + */ + void qsWaveMixCloseSession(); + + /** + * Stops a sound from playing + */ + void qsWaveMixFreeWave(Audio::SoundHandle &handle); + + /** + * Flushes a channel + */ + void qsWaveMixFlushChannel(int iChannel, uint flags = 0); + + /** + * Sets the amount of time, in milliseconds, to effect a change in + * a channel property (e.g. volume, position). Non-zero values + * smooth out changes + * @param iChannel Channel to change + * @param flags Flags + * @param rate Pan rate in milliseconds + */ + void qsWaveMixSetPanRate(int iChannel, uint flags, uint rate); + + /** + * Sets the volume for a channel + */ + void qsWaveMixSetVolume(int iChannel, uint flags, uint volume); + + /** + * Sets the relative position of a channel + * @param iChannel Channel number + * @param Flags Flags + * @param position Vector position for channel + */ + void qsWaveMixSetSourcePosition(int iChannel, uint flags, const QSVECTOR &position); + + /** + * Sets the relative position of a channel using polar co-ordinates + * @param iChannel Channel number + * @param Flags Flags + * @param position Polar position for channel + */ + void qsWaveMixSetPolarPosition(int iChannel, uint flags, const QSPOLAR &position); + + /** + * Sets the listener position + */ + void qsWaveMixSetListenerPosition(const QSVECTOR &position, uint flags = 0); + + /** + * Sets the listener orientation + */ + void qsWaveMixSetListenerOrientation(const QSVECTOR &direction, const QSVECTOR &up, uint flags = 0); + + /** + * Sets the mapping ditance range + */ + void qsWaveMixSetDistanceMapping(int iChannel, uint flags, const QMIX_DISTANCES &distances); + + /** + * + */ + void qsWaveMixSetFrequency(int iChannel, uint flags, uint frequency); + + /** + * Sets the velocity of the source (listener) + */ + void qsWaveMixSetSourceVelocity(int iChannel, uint flags, const QSVECTOR &velocity); + + /** + * Plays sound + * @param iChannel The channel number to be played on + * @param flags Play flags + * @param mixWave Data for the sound to be played + * @param loops Number of loops to play (-1 for forever) + * @param params Playback parameter data + */ + int qsWaveMixPlayEx(int iChannel, uint flags, CWaveFile *waveFile, int loops, const QMIXPLAYPARAMS ¶ms); + + /** + * Returns true if there are no more buffers playing or queued on the channel + */ + bool qsWaveMixIsChannelDone(int iChannel) const; + + /** + * Handles regularly updating the mixer + */ + void qsWaveMixPump(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_QMIXER_H */ diff --git a/engines/titanic/sound/restricted_auto_music_player.cpp b/engines/titanic/sound/restricted_auto_music_player.cpp new file mode 100644 index 0000000000..2384d4da25 --- /dev/null +++ b/engines/titanic/sound/restricted_auto_music_player.cpp @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/restricted_auto_music_player.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CRestrictedAutoMusicPlayer, CAutoMusicPlayer) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + +void CRestrictedAutoMusicPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_oldNodeName, indent); + file->writeQuotedLine(_newNodeName, indent); + file->writeQuotedLine(_newRoomName, indent); + file->writeQuotedLine(_oldRoomName, indent); + + CAutoMusicPlayer::save(file, indent); +} + +void CRestrictedAutoMusicPlayer::load(SimpleFile *file) { + file->readNumber(); + _oldNodeName = file->readString(); + _newNodeName = file->readString(); + _newRoomName = file->readString(); + _oldRoomName = file->readString(); + + CAutoMusicPlayer::load(file); +} + +bool CRestrictedAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) { + if (!msg->_oldRoom) + return true; + if (petCheckNode(_oldNodeName)) + return false; + + CString roomName = msg->_oldRoom->getName(); + if (_oldRoomName.compareToIgnoreCase(roomName)) { + _isRepeated = true; + return false; + } else { + return CAutoMusicPlayer::EnterRoomMsg(msg); + } +} + +bool CRestrictedAutoMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) { + CString roomName = msg->_newRoom->getName(); + + if (petCheckNode(_newNodeName) || _newRoomName.compareToIgnoreCase(roomName)) { + _isRepeated = false; + return true; + } else { + return CAutoMusicPlayer::LeaveRoomMsg(msg); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/restricted_auto_music_player.h b/engines/titanic/sound/restricted_auto_music_player.h new file mode 100644 index 0000000000..d36ee5a7ab --- /dev/null +++ b/engines/titanic/sound/restricted_auto_music_player.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RESTRICTED_AUTO_MUSIC_PLAYER_H +#define TITANIC_RESTRICTED_AUTO_MUSIC_PLAYER_H + +#include "titanic/sound/auto_music_player.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CRestrictedAutoMusicPlayer : public CAutoMusicPlayer { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); +private: + CString _oldNodeName; + CString _newNodeName; + CString _newRoomName; + CString _oldRoomName; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RESTRICTED_AUTO_MUSIC_PLAYER_H */ diff --git a/engines/titanic/sound/room_auto_sound_player.cpp b/engines/titanic/sound/room_auto_sound_player.cpp new file mode 100644 index 0000000000..cad7c10771 --- /dev/null +++ b/engines/titanic/sound/room_auto_sound_player.cpp @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/room_auto_sound_player.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CRoomAutoSoundPlayer, CAutoSoundPlayer) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + +void CRoomAutoSoundPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CAutoSoundPlayer::save(file, indent); +} + +void CRoomAutoSoundPlayer::load(SimpleFile *file) { + file->readNumber(); + CAutoSoundPlayer::load(file); +} + +bool CRoomAutoSoundPlayer::EnterRoomMsg(CEnterRoomMsg *msg) { + CRoomItem *room = findRoom(); + if (room == msg->_newRoom) { + CTurnOn onMsg; + onMsg.execute(this); + } + + return true; +} + +bool CRoomAutoSoundPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) { + CRoomItem *room = findRoom(); + if (room == msg->_oldRoom) { + CTurnOff offMsg; + offMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/room_auto_sound_player.h b/engines/titanic/sound/room_auto_sound_player.h new file mode 100644 index 0000000000..56525ccfa3 --- /dev/null +++ b/engines/titanic/sound/room_auto_sound_player.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ROOM_AUTO_SOUND_PLAYER_H +#define TITANIC_ROOM_AUTO_SOUND_PLAYER_H + +#include "titanic/sound/auto_sound_player.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CRoomAutoSoundPlayer : public CAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool EnterRoomMsg(CEnterRoomMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ROOM_AUTO_SOUND_PLAYER_H */ diff --git a/engines/titanic/sound/room_trigger_auto_music_player.cpp b/engines/titanic/sound/room_trigger_auto_music_player.cpp new file mode 100644 index 0000000000..7782cef0e2 --- /dev/null +++ b/engines/titanic/sound/room_trigger_auto_music_player.cpp @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/room_trigger_auto_music_player.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CRoomTriggerAutoMusicPlayer, CTriggerAutoMusicPlayer) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +void CRoomTriggerAutoMusicPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CTriggerAutoMusicPlayer::save(file, indent); +} + +void CRoomTriggerAutoMusicPlayer::load(SimpleFile *file) { + file->readNumber(); + CTriggerAutoMusicPlayer::load(file); +} + +bool CRoomTriggerAutoMusicPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) { + if (msg->_oldRoom == findRoom()) { + CTriggerAutoMusicPlayerMsg triggerMsg; + triggerMsg._value = 1; + triggerMsg.execute(this); + } + + return true; +} + +bool CRoomTriggerAutoMusicPlayer::EnterRoomMsg(CEnterRoomMsg *msg) { + if (msg->_newRoom == findRoom()) { + CTriggerAutoMusicPlayerMsg triggerMsg; + triggerMsg._value = 2; + triggerMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/room_trigger_auto_music_player.h b/engines/titanic/sound/room_trigger_auto_music_player.h new file mode 100644 index 0000000000..a57e133eb6 --- /dev/null +++ b/engines/titanic/sound/room_trigger_auto_music_player.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ROOM_TRIGGER_AUTO_MUSIC_PLAYER_H +#define TITANIC_ROOM_TRIGGER_AUTO_MUSIC_PLAYER_H + +#include "titanic/sound/trigger_auto_music_player.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CRoomTriggerAutoMusicPlayer : public CTriggerAutoMusicPlayer { + DECLARE_MESSAGE_MAP; + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool EnterRoomMsg(CEnterRoomMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ROOM_TRIGGER_AUTO_MUSIC_PLAYER_H */ diff --git a/engines/titanic/sound/season_noises.cpp b/engines/titanic/sound/season_noises.cpp new file mode 100644 index 0000000000..ce045488ee --- /dev/null +++ b/engines/titanic/sound/season_noises.cpp @@ -0,0 +1,115 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/season_noises.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CSeasonNoises, CViewAutoSoundPlayer) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + +CSeasonNoises::CSeasonNoises() : CViewAutoSoundPlayer(), _seasonNumber(0), + _springName("NULL"), _summerName("NULL"), _autumnName("NULL"), _winterName("NULL") { +} + +void CSeasonNoises::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_seasonNumber, indent); + file->writeQuotedLine(_springName, indent); + file->writeQuotedLine(_summerName, indent); + file->writeQuotedLine(_autumnName, indent); + file->writeQuotedLine(_winterName, indent); + + CViewAutoSoundPlayer::save(file, indent); +} + +void CSeasonNoises::load(SimpleFile *file) { + file->readNumber(); + _seasonNumber = file->readNumber(); + _springName = file->readString(); + _summerName = file->readString(); + _autumnName = file->readString(); + _winterName = file->readString(); + + CViewAutoSoundPlayer::load(file); +} + +bool CSeasonNoises::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _seasonNumber = (_seasonNumber + 1) % 4; + CActMsg actMsg("Update"); + actMsg.execute(this); + + return true; +} + +bool CSeasonNoises::EnterViewMsg(CEnterViewMsg *msg) { + CActMsg actMsg("Update"); + return true; +} + +bool CSeasonNoises::ActMsg(CActMsg *msg) { + msg->_action = "Update"; + + switch (_seasonNumber) { + case 0: + _filename = _springName; + break; + case 1: + _filename = _summerName; + break; + case 2: + _filename = _autumnName; + break; + case 3: + _filename = _winterName; + break; + default: + break; + } + + CSignalObject signalMsg; + signalMsg._numValue = 2; + signalMsg.execute(this); + + CTurnOn onMsg; + onMsg.execute(this); + + return true; +} + +bool CSeasonNoises::LoadSuccessMsg(CLoadSuccessMsg *msg) { + if (_active) { + _active = false; + _soundHandle = -1; + + CActMsg actMsg("Update"); + actMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/season_noises.h b/engines/titanic/sound/season_noises.h new file mode 100644 index 0000000000..796628d10d --- /dev/null +++ b/engines/titanic/sound/season_noises.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SEASON_NOISES_H +#define TITANIC_SEASON_NOISES_H + +#include "titanic/sound/view_auto_sound_player.h" + +namespace Titanic { + +class CSeasonNoises : public CViewAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool ActMsg(CActMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); +private: + int _seasonNumber; + CString _springName; + CString _summerName; + CString _autumnName; + CString _winterName; +public: + CLASSDEF; + CSeasonNoises(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SEASON_NOISES_H */ diff --git a/engines/titanic/sound/seasonal_music_player.cpp b/engines/titanic/sound/seasonal_music_player.cpp new file mode 100644 index 0000000000..3532311bdf --- /dev/null +++ b/engines/titanic/sound/seasonal_music_player.cpp @@ -0,0 +1,135 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/seasonal_music_player.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CSeasonalMusicPlayer, CAutoMusicPlayerBase) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(ArboretumGateMsg) + ON_MESSAGE(ChangeMusicMsg) +END_MESSAGE_MAP() + +CSeasonalMusicPlayer::CSeasonalMusicPlayer() : CAutoMusicPlayerBase() { + _isSpring = false; + _isSummer = true; + _isAutumn = false; + _isWinter = false; + _springMode = -4; + _summerMode = -2; + _autumnMode = -4; + _winterMode = -4; +} + +void CSeasonalMusicPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_isSpring, indent); + file->writeNumberLine(_isSummer, indent); + file->writeNumberLine(_isAutumn, indent); + file->writeNumberLine(_isWinter, indent); + file->writeNumberLine(_springMode, indent); + file->writeNumberLine(_summerMode, indent); + file->writeNumberLine(_autumnMode, indent); + file->writeNumberLine(_winterMode, indent); + + CAutoMusicPlayerBase::save(file, indent); +} + +void CSeasonalMusicPlayer::load(SimpleFile *file) { + file->readNumber(); + _isSpring = file->readNumber(); + _isSummer = file->readNumber(); + _isAutumn = file->readNumber(); + _isWinter = file->readNumber(); + _springMode = file->readNumber(); + _summerMode = file->readNumber(); + _autumnMode = file->readNumber(); + _winterMode = file->readNumber(); + + CAutoMusicPlayerBase::load(file); +} + +bool CSeasonalMusicPlayer::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _isSpring = msg->_season == "spring"; + _isSummer = msg->_season == "summer"; + _isAutumn = msg->_season == "autumn"; + _isWinter = msg->_season == "winter"; + + _springMode = _isSpring ? -2 : -4; + _summerMode = _isSummer ? -2 : -4; + _autumnMode = _isAutumn ? -2 : -4; + _winterMode = _isWinter ? -2 : -4; + + CChangeMusicMsg changeMsg; + changeMsg._filename = msg->_season; + changeMsg.execute(this); + + return true; +} + +bool CSeasonalMusicPlayer::ArboretumGateMsg(CArboretumGateMsg *msg) { + CChangeMusicMsg changeMsg; + changeMsg._flags = msg->_value ? 2 : 1; + changeMsg.execute(this); + + return true; +} + +bool CSeasonalMusicPlayer::ChangeMusicMsg(CChangeMusicMsg *msg) { + if (_isRepeated && msg->_flags == 1) { + _isRepeated = false; + stopGlobalSound(_transition, -1); + } + + if (!msg->_filename.empty()) { + if (_isSummer) { + setGlobalSoundVolume(-4, 2, 0); + setGlobalSoundVolume(-2, 2, 1); + } else if (_isAutumn) { + setGlobalSoundVolume(-4, 2, 1); + setGlobalSoundVolume(-2, 2, 2); + } else if (_isWinter) { + setGlobalSoundVolume(-4, 2, 2); + setGlobalSoundVolume(-2, 2, 3); + } else if (_isSpring) { + setGlobalSoundVolume(-4, 2, 3); + setGlobalSoundVolume(-2, 2, 0); + } + } + + if (!_isRepeated && msg->_flags == 2) { + _isRepeated = true; + loadSound("c#64.wav"); + loadSound("c#63.wav"); + loadSound("c#65.wav"); + loadSound("c#62.wav"); + playGlobalSound("c#64.wav", _springMode, _isSpring, true, 0); + playGlobalSound("c#63.wav", _summerMode, _isSummer, true, 1); + playGlobalSound("c#65.wav", _autumnMode, _isAutumn, true, 2); + playGlobalSound("c#62.wav", _winterMode, _isWinter, true, 3); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/seasonal_music_player.h b/engines/titanic/sound/seasonal_music_player.h new file mode 100644 index 0000000000..d6a79d73da --- /dev/null +++ b/engines/titanic/sound/seasonal_music_player.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SEASONAL_MUSIC_PLAYER_H +#define TITANIC_SEASONAL_MUSIC_PLAYER_H + +#include "titanic/sound/auto_music_player_base.h" + +namespace Titanic { + +class CSeasonalMusicPlayer : public CAutoMusicPlayerBase { + DECLARE_MESSAGE_MAP; + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool ArboretumGateMsg(CArboretumGateMsg *msg); + bool ChangeMusicMsg(CChangeMusicMsg *msg); +private: + bool _isSpring; + bool _isSummer; + bool _isAutumn; + bool _isWinter; + int _springMode; + int _summerMode; + int _autumnMode; + int _winterMode; +public: + CLASSDEF; + CSeasonalMusicPlayer(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SEASONAL_MUSIC_PLAYER_H */ diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp new file mode 100644 index 0000000000..7e791c2ba5 --- /dev/null +++ b/engines/titanic/sound/sound.cpp @@ -0,0 +1,223 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/sound.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CSound::CSound(CGameManager *owner, Audio::Mixer *mixer) : + _gameManager(owner), _soundManager(mixer) { + g_vm->_movieManager.setSoundManager(&_soundManager); +} + +void CSound::save(SimpleFile *file) const { + _soundManager.save(file); +} + +void CSound::load(SimpleFile *file) { + _soundManager.load(file); +} + +void CSound::preLoad() { + _soundManager.preLoad(); + + if (_gameManager) + _gameManager->_musicRoom.destroyMusicHandler(); +} + +void CSound::preEnterView(CViewItem *newView, bool isNewRoom) { + CNodeItem *node = newView->findNode(); + double xp, yp, zp; + node->getPosition(xp, yp, zp); + + double cosVal = cos(newView->_angle); + double sinVal = -sin(newView->_angle); + + _soundManager.setListenerPosition(xp, yp, zp, cosVal, sinVal, 0, isNewRoom); +} + +bool CSound::isActive(int handle) const { + if (handle != 0 && handle != -1) + return _soundManager.isActive(handle); + + return false; +} + +void CSound::setVolume(uint handle, uint volume, uint seconds) { + _soundManager.setVolume(handle, volume, seconds); +} + +void CSound::activateSound(CWaveFile *waveFile, bool freeFlag) { + for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { + CSoundItem *sound = *i; + if (sound->_waveFile == waveFile) { + sound->_active = true; + sound->_freeFlag = freeFlag; + + if (!freeFlag && waveFile->size() > 51200) + sound->_freeFlag = true; + break; + } + } +} + +void CSound::stopChannel(int channel) { + _soundManager.stopChannel(channel); +} + +void CSound::checkSounds() { + for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { + CSoundItem *soundItem = *i; + if (soundItem->_active && soundItem->_freeFlag) { + if (_soundManager.isActive(soundItem->_waveFile)) { + _sounds.remove(soundItem); + delete soundItem; + } + } + } +} + +void CSound::removeOldest() { + for (CSoundItemList::iterator i = _sounds.reverse_begin(); + i != _sounds.end(); --i) { + CSoundItem *soundItem = *i; + if (soundItem->_active && !_soundManager.isActive(soundItem->_waveFile)) { + _sounds.remove(soundItem); + delete soundItem; + break; + } + } +} + +CWaveFile *CSound::getTrueTalkSound(CDialogueFile *dialogueFile, int index) { + return loadSpeech(dialogueFile, index); +} + +CWaveFile *CSound::loadSound(const CString &name) { + checkSounds(); + + // Check whether an entry for the given name is already active + for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { + CSoundItem *soundItem = *i; + if (soundItem->_name == name) { + // Found it, so move it to the front of the list and return + _sounds.remove(soundItem); + _sounds.push_front(soundItem); + return soundItem->_waveFile; + } + } + + // Create new sound item + CSoundItem *soundItem = new CSoundItem(name); + soundItem->_waveFile = _soundManager.loadSound(name); + + if (!soundItem->_waveFile) { + // Couldn't load sound, so destroy new item and return + delete soundItem; + return 0; + } + + // Add the item to the list of sounds + _sounds.push_front(soundItem); + + // If there are more than 10 sounds loaded, remove the last one, + // which is the least recently used of all of them + if (_sounds.size() > 10) + removeOldest(); + + return soundItem->_waveFile; +} + +int CSound::playSound(const CString &name, CProximity &prox) { + CWaveFile *waveFile = loadSound(name); + if (!waveFile) + return -1; + + prox._field6C = waveFile->fn1(); + activateSound(waveFile, prox._freeSoundFlag); + + return _soundManager.playSound(*waveFile, prox); +} + +CWaveFile *CSound::loadSpeech(CDialogueFile *dialogueFile, int speechId) { + checkSounds(); + + // Check whether an entry for the given name is already active + for (CSoundItemList::iterator i = _sounds.begin(); i != _sounds.end(); ++i) { + CSoundItem *soundItem = *i; + if (soundItem->_dialogueFileHandle == dialogueFile->getFile() + && soundItem->_speechId == speechId) { + // Found it, so move it to the front of the list and return + _sounds.remove(soundItem); + _sounds.push_front(soundItem); + return soundItem->_waveFile; + } + } + + // Create new sound item + CSoundItem *soundItem = new CSoundItem(dialogueFile->getFile(), speechId); + soundItem->_waveFile = _soundManager.loadSpeech(dialogueFile, speechId); + + if (!soundItem->_waveFile) { + // Couldn't load speech, so destroy new item and return + delete soundItem; + return 0; + } + + // Add the item to the list of sounds + _sounds.push_front(soundItem); + + // If there are more than 10 sounds loaded, remove the last one, + // which is the least recently used of all of them + if (_sounds.size() > 10) + removeOldest(); + + return soundItem->_waveFile; +} + +int CSound::playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox) { + CWaveFile *waveFile = loadSpeech(dialogueFile, speechId); + if (!waveFile) + return -1; + + prox._field6C = waveFile->fn1(); + activateSound(waveFile, prox._freeSoundFlag); + + return _soundManager.playSound(*waveFile, prox); +} + +void CSound::stopSound(uint handle) { + _soundManager.stopSound(handle); +} + +void CSound::setCanFree(int handle) { + if (handle != 0 && handle != -1) + _soundManager.setCanFree(handle); +} + +void CSound::updateMixer() { + _soundManager.waveMixPump(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h new file mode 100644 index 0000000000..de95f9edf1 --- /dev/null +++ b/engines/titanic/sound/sound.h @@ -0,0 +1,190 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SOUND_H +#define TITANIC_SOUND_H + +#include "titanic/support/simple_file.h" +#include "titanic/sound/proximity.h" +#include "titanic/sound/sound_manager.h" +#include "titanic/sound/wave_file.h" +#include "titanic/core/list.h" +#include "titanic/core/view_item.h" +#include "titanic/true_talk/dialogue_file.h" + +namespace Titanic { + +class CGameManager; + +class CSoundItem : public ListItem { +public: + CString _name; + CWaveFile *_waveFile; + File *_dialogueFileHandle; + int _speechId; + bool _freeFlag; + bool _active; +public: + CSoundItem() : ListItem(), _waveFile(nullptr), _dialogueFileHandle(nullptr), + _speechId(0), _freeFlag(false), _active(false) {} + CSoundItem(const CString &name) : ListItem(), _name(name), _waveFile(nullptr), + _dialogueFileHandle(nullptr), _speechId(0), _freeFlag(false), _active(false) {} + CSoundItem(File *dialogueFile, int speechId) : ListItem(), _waveFile(nullptr), + _dialogueFileHandle(dialogueFile), _speechId(speechId), _freeFlag(false), _active(false) {} +}; + +class CSoundItemList : public List<CSoundItem> { +}; + +class CSound { +private: + CGameManager *_gameManager; + CSoundItemList _sounds; +private: + /** + * Check whether any sounds are done and can be be removed + */ + void checkSounds(); + + /** + * Removes the oldest sound from the sounds list that isn't + * currently playing + */ + void removeOldest(); +public: + QSoundManager _soundManager; +public: + CSound(CGameManager *owner, Audio::Mixer *mixer); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file) const; + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file); + + /** + * Called when a game is about to be loaded + */ + void preLoad(); + + /** + * Called when loading a game is complete + */ + void postLoad() { _soundManager.postLoad(); } + + /** + * Called when a game is about to be saved + */ + void preSave() { _soundManager.preSave(); } + + /** + * Called when a game has finished being saved + */ + void postSave() { _soundManager.postSave(); } + + /** + * Called when the view has been changed + */ + void preEnterView(CViewItem *newView, bool isNewRoom); + + /** + * Returns true if a sound with the specified handle is active + */ + bool isActive(int handle) const; + + /** + * Sets the volume for a sound + * @param handle Sound handle + * @param volume Volume percentage (0 to 100) + * @param seconds Number of seconds to transition to the new volume + */ + void setVolume(uint handle, uint volume, uint seconds); + + /** + * Flags a sound about to be played as activated + */ + void activateSound(CWaveFile *waveFile, bool freeFlag); + + /** + * Stops any sounds attached to a given channel + */ + void stopChannel(int channel); + + /** + * Loads a TrueTalk dialogue + * @param dialogueFile Dialogue file reference + * @param speechId Speech Id within dialogue + * @returns Wave file instance + */ + CWaveFile *getTrueTalkSound(CDialogueFile *dialogueFile, int index); + + /** + * Load a speech resource + * @param dialogueFile Dialogue file reference + * @param speechId Speech Id within dialogue + * @returns Wave file instance + */ + CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId); + + /** + * Play a speech + * @param dialogueFile Dialogue file reference + * @param speechId Speech Id within dialogue + * @param prox Proximity instance + */ + int playSpeech(CDialogueFile *dialogueFile, int speechId, CProximity &prox); + + /** + * Load a sound + * @param name Name of sound resource + * @returns Sound item record + */ + CWaveFile *loadSound(const CString &name); + + /** + * Play a sound + */ + int playSound(const CString &name, CProximity &prox); + + /** + * Stop a sound + */ + void stopSound(uint handle); + + /** + * Flags that a sound can be freed if a timeout is set + */ + void setCanFree(int handle); + + /** + * Handles regularly updating the mixer + */ + void updateMixer(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SOUND_H */ diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp new file mode 100644 index 0000000000..84d38ed2ab --- /dev/null +++ b/engines/titanic/sound/sound_manager.cpp @@ -0,0 +1,480 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/sound_manager.h" +#include "titanic/titanic.h" +namespace Titanic { + +const uint SAMPLING_RATE = 22050; +const uint LATENCY = 100; +const uint CHANNELS_COUNT = 16; + +CSoundManager::CSoundManager() : _musicPercent(75.0), _speechPercent(75.0), + _masterPercent(75.0), _parrotPercent(75.0), _handleCtr(1) { +} + +double CSoundManager::getModeVolume(int mode) { + switch (mode) { + case -1: + return _masterPercent; + case -2: + return _masterPercent * 30 / 100; + case -3: + return _masterPercent * 15 / 100; + default: + return 0; + } +} + +/*------------------------------------------------------------------------*/ + +void QSoundManagerSounds::add(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker) { + push_back(new QSoundManagerSound(waveFile, iChannel, endFn, talker)); +} + +void QSoundManagerSounds::flushChannel(int iChannel) { + for (iterator i = begin(); i != end(); ++i) { + QSoundManagerSound *item = *i; + if (item->_iChannel == iChannel) { + if (item->_endFn) + item->_endFn(item->_talker); + + remove(item); + delete item; + break; + } + } +} + +void QSoundManagerSounds::flushChannel(CWaveFile *waveFile, int iChannel) { + for (iterator i = begin(); i != end(); ++i) { + QSoundManagerSound *item = *i; + if (item->_waveFile->isLoaded() && item->_iChannel == iChannel) { + if (item->_endFn) + item->_endFn(item->_talker); + + remove(item); + delete item; + break; + } + } +} + +bool QSoundManagerSounds::contains(const CWaveFile *waveFile) const { + for (const_iterator i = begin(); i != end(); ++i) { + const QSoundManagerSound *item = *i; + if (item->_waveFile == waveFile) + return true; + } + + return false; +} + +/*------------------------------------------------------------------------*/ + +void QSoundManager::Slot::clear() { + _waveFile = nullptr; + _isTimed = false; + _ticks = 0; + _channel = -1; + _handle = 0; + _positioningMode = POSMODE_NONE; +} + +/*------------------------------------------------------------------------*/ + +QSoundManager::QSoundManager(Audio::Mixer *mixer) : CSoundManager(), QMixer(mixer), + _field18(0), _field1C(0) { + _slots.resize(48); + Common::fill(&_channelsVolume[0], &_channelsVolume[16], 0); + Common::fill(&_channelsMode[0], &_channelsMode[16], 0); + + qsWaveMixInitEx(QMIXCONFIG(SAMPLING_RATE, CHANNELS_COUNT, LATENCY)); + qsWaveMixActivate(true); + qsWaveMixOpenChannel(0, QMIX_OPENALL); +} + +QSoundManager::~QSoundManager() { + // Close down the mixer + qsWaveMixCloseSession(); +} + +CWaveFile *QSoundManager::loadSound(const CString &name) { + CWaveFile *waveFile = new CWaveFile(); + + // Try to load the specified sound + if (!waveFile->loadSound(name)) { + delete waveFile; + return nullptr; + } + + return waveFile; +} + +CWaveFile *QSoundManager::loadSpeech(CDialogueFile *dialogueFile, int speechId) { + CWaveFile *waveFile = new CWaveFile(); + + // Try to load the specified sound + if (!waveFile->loadSpeech(dialogueFile, speechId)) { + delete waveFile; + return nullptr; + } + + return waveFile; +} + +CWaveFile *QSoundManager::loadMusic(const CString &name) { + CWaveFile *waveFile = new CWaveFile(); + + // Try to load the specified sound + if (!waveFile->loadMusic(name)) { + delete waveFile; + return nullptr; + } + + return waveFile; +} + +int QSoundManager::playSound(CWaveFile &waveFile, CProximity &prox) { + int channel = -1; + uint flags = QMIX_CLEARQUEUE; + + if (prox._priorSoundHandle >= 1) { + // This sound should only be started after a prior one finishes, + // so scan the slots for the specified sound + for (uint idx = 0; idx < _slots.size(); ++idx) { + if (_slots[idx]._handle == prox._priorSoundHandle) { + channel = _slots[idx]._channel; + flags = QMIX_QUEUEWAVE; + break; + } + } + } + + if (channel >= 0 || (channel = resetChannel(prox._channel)) != -1) { + return playWave(&waveFile, channel, flags, prox); + } + + return 0; +} + +void QSoundManager::stopSound(int handle) { + resetChannel(10); + + for (uint idx = 0; idx < _slots.size(); ++idx) { + Slot &slot = _slots[idx]; + if (slot._handle == handle) { + qsWaveMixFlushChannel(slot._channel); + _sounds.flushChannel(slot._channel); + resetChannel(10); + } + } +} + +void QSoundManager::stopChannel(int channel) { + int endChannel; + switch (channel) { + case 0: + case 3: + endChannel = channel + 3; + break; + case 6: + endChannel = 10; + break; + case 10: + endChannel = 48; + break; + default: + return; + } + + for (; channel < endChannel; ++channel) { + qsWaveMixFlushChannel(channel); + _sounds.flushChannel(channel); + } +} + +void QSoundManager::setCanFree(int handle) { + for (uint idx = 0; idx < _slots.size(); ++idx) { + if (_slots[idx]._handle == handle) + _slots[idx]._isTimed = true; + } +} + +void QSoundManager::stopAllChannels() { + qsWaveMixFlushChannel(0, QMIX_OPENALL); + + for (int idx = 0; idx < 16; ++idx) + _sounds.flushChannel(idx); + resetChannel(10); +} + +int QSoundManager::resetChannel(int iChannel) { + int newChannel = -1; + int channelStart = 10; + int channelEnd = 16; + + if (iChannel != 10) { + qsWaveMixFlushChannel(iChannel); + _sounds.flushChannel(iChannel); + channelStart = iChannel; + channelEnd = iChannel + 1; + } else { + uint ticks = g_vm->_events->getTicksCount(); + + for (uint idx = 0; idx < _slots.size(); ++idx) { + Slot &slot = _slots[idx]; + if (slot._isTimed && slot._ticks && ticks > slot._ticks) { + qsWaveMixFlushChannel(slot._channel); + _sounds.flushChannel(slot._channel); + } + } + } + + for (iChannel = channelStart; iChannel < channelEnd; ++iChannel) { + if (qsWaveMixIsChannelDone(iChannel)) { + // Scan through the slots, and reset any slot using the channel + for (uint idx = 0; idx < _slots.size(); ++idx) { + Slot &slot = _slots[idx]; + if (slot._channel == iChannel) + slot.clear(); + } + + // Use the empty channel + newChannel = iChannel; + } + } + + return newChannel; +} + +void QSoundManager::setVolume(int handle, uint volume, uint seconds) { + for (uint idx = 0; idx < _slots.size(); ++idx) { + Slot &slot = _slots[idx]; + if (slot._handle == handle) { + _channelsVolume[slot._channel] = volume; + updateVolume(slot._channel, seconds * 1000); + + if (volume) { + uint ticks = g_vm->_events->getTicksCount() + seconds * 1000; + if (!slot._ticks || ticks >= slot._ticks) + slot._ticks = ticks; + } else { + slot._ticks = 0; + } + break; + } + } +} + +void QSoundManager::setVectorPosition(int handle, double x, double y, double z, uint panRate) { + for (uint idx = 0; idx < _slots.size(); ++idx) { + Slot &slot = _slots[idx]; + if (slot._handle == handle) { + qsWaveMixSetPanRate(slot._channel, QMIX_USEONCE, panRate); + qsWaveMixSetSourcePosition(slot._channel, QMIX_USEONCE, QSVECTOR(x, y, z)); + break; + } + } +} + +void QSoundManager::setPolarPosition(int handle, double range, double azimuth, double elevation, uint panRate) { + for (uint idx = 0; idx < _slots.size(); ++idx) { + Slot &slot = _slots[idx]; + if (slot._handle == handle) { + qsWaveMixSetPanRate(slot._channel, QMIX_USEONCE, panRate); + qsWaveMixSetPolarPosition(slot._channel, QMIX_USEONCE, + QSPOLAR(azimuth, range, elevation)); + break; + } + } +} + +bool QSoundManager::isActive(int handle) const { + for (uint idx = 0; idx < _slots.size(); ++idx) { + if (_slots[idx]._handle == handle) + return true; + } + + return false; +} + +bool QSoundManager::isActive(const CWaveFile *waveFile) const { + return _sounds.contains(waveFile); +} + +void QSoundManager::waveMixPump() { + qsWaveMixPump(); +} + +uint QSoundManager::getLatency() const { + return LATENCY; +} + +void QSoundManager::setMusicPercent(double percent) { + _musicPercent = percent; + updateVolumes(); +} + +void QSoundManager::setSpeechPercent(double percent) { + _speechPercent = percent; + updateVolumes(); +} + +void QSoundManager::setMasterPercent(double percent) { + _masterPercent = percent; + updateVolumes(); +} + +void QSoundManager::setParrotPercent(double percent) { + _parrotPercent = percent; +} + +void QSoundManager::setListenerPosition(double posX, double posY, double posZ, + double directionX, double directionY, double directionZ, bool stopSounds) { + if (stopSounds) { + // Stop any running sounds + for (uint idx = 0; idx < _slots.size(); ++idx) { + if (_slots[idx]._positioningMode != 0) + stopSound(_slots[idx]._handle); + } + } + + qsWaveMixSetListenerPosition(QSVECTOR(posX, posY, posZ)); + qsWaveMixSetListenerOrientation(QSVECTOR(directionX, directionY, directionZ), + QSVECTOR(0.0, 0.0, -1.0)); +} + +int QSoundManager::playWave(CWaveFile *waveFile, int iChannel, uint flags, CProximity &prox) { + if (!waveFile || !waveFile->isLoaded()) + return 0; + + prox._channelVolume = CLIP(prox._channelVolume, 0, 100); + prox._fieldC = CLIP(prox._fieldC, -100, 100); + + int slotIndex = findFreeSlot(); + if (slotIndex == -1) + return -1; + + switch (prox._positioningMode) { + case POSMODE_POLAR: + qsWaveMixSetPolarPosition(iChannel, 8, QSPOLAR(prox._azimuth, prox._range, prox._elevation)); + qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true); + qsWaveMixSetDistanceMapping(iChannel, 8, QMIX_DISTANCES(5.0, 3.0, 1.0)); + break; + + case POSMODE_VECTOR: + qsWaveMixSetSourcePosition(iChannel, 8, QSVECTOR(prox._posX, prox._posY, prox._posZ)); + qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true); + qsWaveMixSetDistanceMapping(iChannel, 8, QMIX_DISTANCES(5.0, 3.0, 1.0)); + break; + + default: + qsWaveMixEnableChannel(iChannel, QMIX_CHANNEL_ELEVATION, true); + qsWaveMixSetPolarPosition(iChannel, 8, QSPOLAR(0.0, 1.0, 0.0)); + break; + } + + if (prox._frequencyMultiplier || prox._field1C != 1.875) { + uint freq = (uint)(waveFile->getFrequency() * prox._frequencyMultiplier); + qsWaveMixSetFrequency(iChannel, 8, freq); + } + + _sounds.add(waveFile, iChannel, prox._endTalkerFn, prox._talker); + + QMIXPLAYPARAMS playParams; + playParams.callback = soundFinished; + playParams.dwUser = this; + if (!qsWaveMixPlayEx(iChannel, flags, waveFile, prox._repeated ? -1 : 0, playParams)) { + Slot &slot = _slots[slotIndex]; + slot._handle = _handleCtr++; + slot._channel = iChannel; + slot._waveFile = waveFile; + slot._positioningMode = prox._positioningMode; + + return slot._handle; + } else { + _sounds.flushChannel(waveFile, iChannel); + if (prox._freeSoundFlag) + delete waveFile; + return 0; + } +} + +void QSoundManager::soundFreed(Audio::SoundHandle &handle) { + qsWaveMixFreeWave(handle); +} + +void QSoundManager::updateVolume(int channel, uint panRate) { + uint volume = _channelsVolume[channel] * 327; + + switch (_channelsMode[channel]) { + case 0: + case 1: + case 2: + volume = (_speechPercent * volume) / 100; + break; + case 3: + case 4: + case 5: + volume = (24525 * volume) / 100; + break; + case 6: + case 7: + case 8: + case 9: + volume = (_masterPercent * volume) / 100; + break; + default: + break; + } + + volume = (_musicPercent * volume) / 100; + qsWaveMixSetPanRate(channel, 0, panRate); + qsWaveMixSetVolume(channel, 0, volume); +} + +void QSoundManager::updateVolumes() { + for (uint idx = 0; idx < CHANNELS_COUNT; ++idx) + updateVolume(idx, 250); +} + +void QSoundManager::soundFinished(int iChannel, CWaveFile *waveFile, void *soundManager) { + static_cast<QSoundManager *>(soundManager)->_sounds.flushChannel(waveFile, iChannel); +} + +int QSoundManager::findFreeSlot() { + for (uint idx = 0; idx < _slots.size(); ++idx) { + if (!_slots[idx]._waveFile) + return idx; + } + + return -1; +} + +void QSoundManager::setChannelVolume(int iChannel, uint volume, uint mode) { + _channelsVolume[iChannel] = volume; + _channelsMode[iChannel] = mode; + updateVolume(iChannel, 250); +} + +} // End of namespace Titanic z diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h new file mode 100644 index 0000000000..3dfba92e9c --- /dev/null +++ b/engines/titanic/sound/sound_manager.h @@ -0,0 +1,454 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SOUND_MANAGER_H +#define TITANIC_SOUND_MANAGER_H + +#include "titanic/core/list.h" +#include "titanic/support/simple_file.h" +#include "titanic/sound/proximity.h" +#include "titanic/sound/qmixer.h" +#include "titanic/sound/wave_file.h" +#include "titanic/true_talk/dialogue_file.h" + +namespace Titanic { + +/** + * Abstract interface class for a sound manager + */ +class CSoundManager { +protected: + double _musicPercent; + double _speechPercent; + double _masterPercent; + double _parrotPercent; + uint _handleCtr; +public: + CSoundManager(); + virtual ~CSoundManager() {} + + /** + * Loads a sound + * @param name Name of sound resource + * @returns Loaded wave file + */ + virtual CWaveFile *loadSound(const CString &name) { return nullptr; } + + /** + * Loads a speech resource from a dialogue file + * @param name Name of sound resource + * @returns Loaded wave file + */ + virtual CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId) { return 0; } + + /** + * Loads a music file + * @param name Name of music resource + * @returns Loaded wave file + * @remarks The original created a streaming audio buffer for the wave file, + * and passed this to the method. For ScummVM, this has been discarded + * in favor of simply passing the filename. + */ + virtual CWaveFile *loadMusic(const CString &name) { return nullptr; } + + /** + * Start playing a previously loaded wave file + */ + virtual int playSound(CWaveFile &waveFile, CProximity &prox) = 0; + + /** + * Stop playing the specified sound + */ + virtual void stopSound(int handle) = 0; + + /** + * Stops a designated range of channels + */ + virtual void stopChannel(int channel) = 0; + + virtual void proc9(int handle) {} + + /** + * Stops sounds on all playing channels + */ + virtual void stopAllChannels() = 0; + + /** + * Sets the volume for a sound + * @param handle Handle for sound + * @param volume New volume + * @param seconds Number of seconds to transition to the new volume + */ + virtual void setVolume(int handle, uint volume, uint seconds) = 0; + + /** + * Set the position for a sound + * @param handle Handle for sound + * @param x x position in metres + * @param y y position in metres + * @param z z position in metres + * @param panRate Rate in milliseconds to transition + */ + virtual void setVectorPosition(int handle, double x, double y, double z, uint panRate) {} + + /** + * Set the position for a sound + * @param handle Handle for sound + * @param range Range value in metres + * @param azimuth Azimuth value in degrees + * @param elevation Elevation value in degrees + * @param panRate Rate in milliseconds to transition + */ + virtual void setPolarPosition(int handle, double range, double azimuth, double elevation, uint panRate) {} + + /** + * Returns true if the given sound is currently active + */ + virtual bool isActive(int handle) const = 0; + + /** + * Returns true if the given sound is currently active + */ + virtual bool isActive(const CWaveFile *waveFile) const { return false; } + + /** + * Handles regularly updating the mixer + */ + virtual void waveMixPump() = 0; + + /** + * Returns the movie latency + */ + virtual uint getLatency() const { return 0; } + + /** + * Sets the music volume percent + */ + virtual void setMusicPercent(double percent) = 0; + + /** + * Sets the speech volume percent + */ + virtual void setSpeechPercent(double percent) = 0; + + /** + * Sets the master volume percent + */ + virtual void setMasterPercent(double percent) = 0; + + /** + * Sets the Parrot NPC volume percent + */ + virtual void setParrotPercent(double percent) = 0; + + /** + * Called when a game is about to be loaded + */ + virtual void preLoad() { stopAllChannels(); } + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file) {} + + /** + * Called after loading of a game is completed + */ + virtual void postLoad() {} + + /** + * Called when a game is about to be saved + */ + virtual void preSave() {} + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file) const {} + + /** + * Called after saving is complete + */ + virtual void postSave() {} + + /** + * Sets the position and orientation for the listener (player) + */ + virtual void setListenerPosition(double posX, double posY, double posZ, + double directionX, double directionY, double directionZ, bool stopSounds) {} + + /** + * Returns the music volume percent + */ + double getMusicVolume() const { return _musicPercent; } + + /** + * Returns the speech volume percent + */ + double getSpeechVolume() const { return _speechPercent; } + + /** + * Returns the parrot volume percent + */ + double getParrotVolume() const { return _parrotPercent; } + + /** + * Gets the volume for a given mode? value + */ + double getModeVolume(int mode); +}; + +class QSoundManagerSound : public ListItem { +public: + CWaveFile *_waveFile; + int _iChannel; + CEndTalkerFn _endFn; + TTtalker *_talker; +public: + QSoundManagerSound() : ListItem(), _waveFile(nullptr), + _iChannel(0), _endFn(nullptr), _talker(nullptr) {} + QSoundManagerSound(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker) : + ListItem(), _waveFile(waveFile), _iChannel(iChannel), _endFn(endFn), _talker(talker) {} +}; + +class QSoundManagerSounds : public List<QSoundManagerSound> { +public: + /** + * Adds a new sound entry to the list + */ + void add(CWaveFile *waveFile, int iChannel, CEndTalkerFn endFn, TTtalker *talker); + + /** + * Flushes a wave file attached to the specified channel + */ + void flushChannel(int iChannel); + + /** + * Flushes a wave file attached to the specified channel + */ + void flushChannel(CWaveFile *waveFile, int iChannel); + + /** + * Returns true if the list contains the specified wave file + */ + bool contains(const CWaveFile *waveFile) const; +}; + +/** + * Concrete sound manager class that handles interfacing with + * the QMixer sound mixer class + */ +class QSoundManager : public CSoundManager, public QMixer { + struct Slot { + CWaveFile *_waveFile; + bool _isTimed; + uint _ticks; + int _channel; + int _handle; + PositioningMode _positioningMode; + + Slot() : _waveFile(0), _isTimed(0), _ticks(0), _channel(-1), + _handle(0), _positioningMode(POSMODE_NONE) {} + void clear(); + }; +private: + QSoundManagerSounds _sounds; + Common::Array<Slot> _slots; + uint _channelsVolume[16]; + int _channelsMode[16]; +private: + /** + * Updates the volume for a channel + * @param channel Channel to be update + * @param panRate Time in milliseconds for change to occur + */ + void updateVolume(int channel, uint panRate); + + /** + * Updates all the volumes + */ + void updateVolumes(); + + /** + * Called by the QMixer when a sound finishes playing + */ + static void soundFinished(int iChannel, CWaveFile *waveFile, void *soundManager); + + /** + * Finds the first free slot + */ + int findFreeSlot(); + + /** + * Sets a channel volume + */ + void setChannelVolume(int iChannel, uint volume, uint mode); + + /** + * Resets the specified channel and returns a new free one + */ + int resetChannel(int iChannel); +public: + int _field18; + int _field1C; + +public: + QSoundManager(Audio::Mixer *mixer); + virtual ~QSoundManager(); + + /** + * Loads a sound + * @param name Name of sound resource + * @returns Loaded wave file + */ + virtual CWaveFile *loadSound(const CString &name); + + /** + * Loads a speech resource from a dialogue file + * @param name Name of sound resource + * @returns Loaded wave file + */ + virtual CWaveFile *loadSpeech(CDialogueFile *dialogueFile, int speechId); + + /** + * Loads a music file + * @param name Name of music resource + * @returns Loaded wave file + * @remarks The original created a streaming audio buffer for the wave file, + * and passed this to the method. For ScummVM, this has been discarded + * in favor of simply passing the filename. + */ + virtual CWaveFile *loadMusic(const CString &name); + + /** + * Start playing a previously loaded sound resource + */ + virtual int playSound(CWaveFile &waveFile, CProximity &prox); + + /** + * Stop playing the specified sound + */ + virtual void stopSound(int handle); + + /** + * Stops a designated range of channels + */ + virtual void stopChannel(int channel); + + /** + * Flags that a sound can be freed if a timeout is set + */ + virtual void setCanFree(int handle); + + /** + * Stops sounds on all playing channels + */ + virtual void stopAllChannels(); + + /** + * Sets the volume for a sound + * @param handle Handle for sound + * @param volume New volume + * @param seconds Number of seconds to transition to the new volume + */ + virtual void setVolume(int handle, uint volume, uint seconds); + + /** + * Set the position for a sound + * @param handle Handle for sound + * @param x x position in metres + * @param y y position in metres + * @param z z position in metres + * @param panRate Rate in milliseconds to transition + */ + virtual void setVectorPosition(int handle, double x, double y, double z, uint panRate); + + /** + * Set the position for a sound + * @param handle Handle for sound + * @param range Range value in metres + * @param azimuth Azimuth value in degrees + * @param elevation Elevation value in degrees + * @param panRate Rate in milliseconds to transition + */ + virtual void setPolarPosition(int handle, double range, double azimuth, double elevation, uint panRate); + + /** + * Returns true if the given sound is currently active + */ + virtual bool isActive(int handle) const; + + /** + * Returns true if the given sound is currently active + */ + virtual bool isActive(const CWaveFile *waveFile) const; + + /** + * Handles regularly updating the mixer + */ + virtual void waveMixPump(); + + /** + * Returns the movie latency + */ + virtual uint getLatency() const; + + /** + * Sets the music volume percent + */ + virtual void setMusicPercent(double percent); + + /** + * Sets the speech volume percent + */ + virtual void setSpeechPercent(double percent); + + /** + * Sets the master volume percent + */ + virtual void setMasterPercent(double percent); + + /** + * Sets the Parrot NPC volume percent + */ + virtual void setParrotPercent(double percent); + + /** + * Sets the position and orientation for the listener (player) + */ + virtual void setListenerPosition(double posX, double posY, double posZ, + double directionX, double directionY, double directionZ, bool stopSounds); + + /** + * Starts a wave file playing + */ + virtual int playWave(CWaveFile *waveFile, int iChannel, uint flags, CProximity &prox); + + /** + * Called when a wave file is freed + */ + void soundFreed(Audio::SoundHandle &handle); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_QSOUND_MANAGER_H */ diff --git a/engines/titanic/sound/titania_speech.cpp b/engines/titanic/sound/titania_speech.cpp new file mode 100644 index 0000000000..a07cc79334 --- /dev/null +++ b/engines/titanic/sound/titania_speech.cpp @@ -0,0 +1,157 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/titania_speech.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CTitaniaSpeech, CGameObject) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(MovieFrameMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + +void CTitaniaSpeech::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_paraNum, indent); + file->writeNumberLine(_frameNum, indent); + + CGameObject::save(file, indent); +} + +void CTitaniaSpeech::load(SimpleFile *file) { + file->readNumber(); + _paraNum = file->readNumber(); + _frameNum = file->readNumber(); + + CGameObject::load(file); +} + +bool CTitaniaSpeech::ActMsg(CActMsg *msg) { + CSetFrameMsg frameMsg; + CVisibleMsg visibleMsg; + CActMsg actMsg; + + if (msg->_action == "TitaniaSpeech") { + switch (_paraNum) { + case 0: + movieSetAudioTiming(true); + loadSound("a#12.wav"); + sleep(1000); + playMovie(0, 187, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + movieEvent(0); + break; + + case 1: + loadSound("a#11.wav"); + addTimer(0); + startAnimTimer("Para2", 300); + addTimer(6000); + addTimer(12000); + addTimer(18000); + addTimer(24000); + startAnimTimer("NextPara", 30000); + break; + + case 2: + visibleMsg._visible = false; + visibleMsg.execute("TitaniaStillControl"); + loadSound("a#10.wav"); + playMovie(585, 706, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playSound("a#10.wav"); + break; + + case 3: + visibleMsg._visible = false; + visibleMsg.execute("TitaniaStillControl"); + loadSound("a#9.wav"); + playMovie(707, 905, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playSound("a#9.wav"); + break; + + case 4: + visibleMsg._visible = false; + visibleMsg.execute("TitaniaStillControl"); + loadSound("a#8.wav"); + playMovie(906, 938, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playSound("a#8.wav"); + break; + + default: + sleep(3000); + actMsg._action = "SleepTitania"; + actMsg.execute(this); + } + } + + return true; +} + +bool CTitaniaSpeech::MovieEndMsg(CMovieEndMsg *msg) { + if (_paraNum == 5) { + startAnimTimer("NextPara", 0); + } else { + if (_paraNum != 1) + addTimer(0); + startAnimTimer("NextPara", 3000); + } + + return true; +} + +bool CTitaniaSpeech::MovieFrameMsg(CMovieFrameMsg *msg) { + int frame = getMovieFrame(); + if (!frame) + playSound("a#12.wav"); + + return true; +} + +bool CTitaniaSpeech::TimerMsg(CTimerMsg *msg) { + CSetFrameMsg frameMsg; + CVisibleMsg visibleMsg; + CActMsg actMsg("TitaniaSpeech"); + + if (msg->_action == "NextPara") { + visibleMsg.execute("TitaniaStillControl"); + ++_paraNum; + actMsg.execute(this); + } else if (msg->_action == "Para2") { + playSound("a#11.wav"); + } else { + frameMsg._frameNumber = _frameNum; + frameMsg.execute("TitaniaStillControl"); + } + + return true; +} + +bool CTitaniaSpeech::EnterRoomMsg(CEnterRoomMsg *msg) { + CActMsg actMsg("Disable"); + actMsg.execute("ShipAnnouncements"); + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/titania_speech.h b/engines/titanic/sound/titania_speech.h new file mode 100644 index 0000000000..2244bb01af --- /dev/null +++ b/engines/titanic/sound/titania_speech.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TITANIA_SPEECH_H +#define TITANIC_TITANIA_SPEECH_H + +#include "titanic/core/game_object.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +class CTitaniaSpeech : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool MovieFrameMsg(CMovieFrameMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool EnterRoomMsg(CEnterRoomMsg *msg); +private: + int _paraNum, _frameNum; +public: + CLASSDEF; + CTitaniaSpeech() : CGameObject(), _paraNum(1), _frameNum(0) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TITANIA_SPEECH_H */ diff --git a/engines/titanic/sound/trigger_auto_music_player.cpp b/engines/titanic/sound/trigger_auto_music_player.cpp new file mode 100644 index 0000000000..a332570aba --- /dev/null +++ b/engines/titanic/sound/trigger_auto_music_player.cpp @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/trigger_auto_music_player.h" +#include "titanic/sound/auto_music_player.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CTriggerAutoMusicPlayer, CGameObject) + ON_MESSAGE(TriggerAutoMusicPlayerMsg) +END_MESSAGE_MAP() + +void CTriggerAutoMusicPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_roomName, indent); + CGameObject::save(file, indent); +} + +void CTriggerAutoMusicPlayer::load(SimpleFile *file) { + file->readNumber(); + _roomName = file->readString(); + CGameObject::load(file); +} + +bool CTriggerAutoMusicPlayer::TriggerAutoMusicPlayerMsg(CTriggerAutoMusicPlayerMsg *msg) { + CRoomItem *room1 = msg->_value == 1 ? locateRoom(_roomName) : findRoom(); + CRoomItem *room2 = msg->_value == 2 ? locateRoom(_roomName) : findRoom(); + + CChangeMusicMsg changeMsg; + changeMsg._flags = 1; + changeMsg.execute(room1, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + + changeMsg._flags = 2; + changeMsg.execute(room2, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/trigger_auto_music_player.h b/engines/titanic/sound/trigger_auto_music_player.h new file mode 100644 index 0000000000..45631e08fc --- /dev/null +++ b/engines/titanic/sound/trigger_auto_music_player.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TRIGGER_AUTO_MUSIC_PLAYER_H +#define TITANIC_TRIGGER_AUTO_MUSIC_PLAYER_H + +#include "titanic/core/game_object.h" + +namespace Titanic { + +class CTriggerAutoMusicPlayer : public CGameObject { + DECLARE_MESSAGE_MAP; + bool TriggerAutoMusicPlayerMsg(CTriggerAutoMusicPlayerMsg *msg); +protected: + CString _roomName; +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TRIGGER_AUTO_MUSIC_PLAYER_H */ diff --git a/engines/titanic/sound/view_auto_sound_player.cpp b/engines/titanic/sound/view_auto_sound_player.cpp new file mode 100644 index 0000000000..55501fe340 --- /dev/null +++ b/engines/titanic/sound/view_auto_sound_player.cpp @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/view_auto_sound_player.h" +#include "titanic/sound/auto_music_player.h" +#include "titanic/core/room_item.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CViewAutoSoundPlayer, CAutoSoundPlayer) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + +void CViewAutoSoundPlayer::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_enabled, indent); + CAutoSoundPlayer::save(file, indent); +} + +void CViewAutoSoundPlayer::load(SimpleFile *file) { + file->readNumber(); + _enabled = file->readNumber(); + CAutoSoundPlayer::load(file); +} + +bool CViewAutoSoundPlayer::EnterViewMsg(CEnterViewMsg *msg) { + CViewItem *view = findView(); + CRoomItem *room = findRoom(); + + if (view == msg->_newView) { + CTurnOn onMsg; + onMsg.execute(this); + + if (_enabled) { + CChangeMusicMsg changeMsg; + changeMsg._flags = 1; + changeMsg.execute(room, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF |MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + } + } + + return true; +} + +bool CViewAutoSoundPlayer::LeaveViewMsg(CLeaveViewMsg *msg) { + CViewItem *view = findView(); + CRoomItem *room = findRoom(); + + if (view == msg->_oldView) { + CTurnOff offMsg; + offMsg.execute(this); + + if (_enabled) { + CChangeMusicMsg changeMsg; + changeMsg._flags = 2; + changeMsg.execute(room, CAutoMusicPlayer::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + } + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/view_auto_sound_player.h b/engines/titanic/sound/view_auto_sound_player.h new file mode 100644 index 0000000000..b62805ea6e --- /dev/null +++ b/engines/titanic/sound/view_auto_sound_player.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_VIEW_AUTO_SOUND_PLAYER_H +#define TITANIC_VIEW_AUTO_SOUND_PLAYER_H + +#include "titanic/sound/auto_sound_player.h" + +namespace Titanic { + +class CViewAutoSoundPlayer : public CAutoSoundPlayer { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); +private: + bool _enabled; +public: + CLASSDEF; + CViewAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(false) {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_VIEW_AUTO_SOUND_PLAYER_H */ diff --git a/engines/titanic/sound/view_toggles_other_music.cpp b/engines/titanic/sound/view_toggles_other_music.cpp new file mode 100644 index 0000000000..731f59bd53 --- /dev/null +++ b/engines/titanic/sound/view_toggles_other_music.cpp @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/sound/view_toggles_other_music.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CViewTogglesOtherMusic, CEnterViewTogglesOtherMusic) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + +CViewTogglesOtherMusic::CViewTogglesOtherMusic() : + CEnterViewTogglesOtherMusic(), _value(1) { +} + +void CViewTogglesOtherMusic::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeNumberLine(_value, indent); + + CEnterViewTogglesOtherMusic::save(file, indent); +} + +void CViewTogglesOtherMusic::load(SimpleFile *file) { + file->readNumber(); + _value = file->readNumber(); + + CEnterViewTogglesOtherMusic::load(file); +} + +bool CViewTogglesOtherMusic::LeaveViewMsg(CLeaveViewMsg *msg) { + if (msg->_oldView == findView()) { + CTriggerAutoMusicPlayerMsg playerMsg(_value); + playerMsg.execute(this); + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/view_toggles_other_music.h b/engines/titanic/sound/view_toggles_other_music.h new file mode 100644 index 0000000000..1b5f110e70 --- /dev/null +++ b/engines/titanic/sound/view_toggles_other_music.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_VIEW_TOGGLES_OTHER_MUSIC_H +#define TITANIC_VIEW_TOGGLES_OTHER_MUSIC_H + +#include "titanic/sound/enter_view_toggles_other_music.h" + +namespace Titanic { + +class CViewTogglesOtherMusic : public CEnterViewTogglesOtherMusic { + DECLARE_MESSAGE_MAP; + bool LeaveViewMsg(CLeaveViewMsg *msg); +private: + int _value; +public: + CLASSDEF; + CViewTogglesOtherMusic(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_VIEW_TOGGLES_OTHER_MUSIC_H */ diff --git a/engines/titanic/sound/water_lapping_sounds.cpp b/engines/titanic/sound/water_lapping_sounds.cpp new file mode 100644 index 0000000000..7616c4b43b --- /dev/null +++ b/engines/titanic/sound/water_lapping_sounds.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include "titanic/sound/water_lapping_sounds.h" + +namespace Titanic { + +EMPTY_MESSAGE_MAP(CWaterLappingSounds, CRoomAutoSoundPlayer); + +CWaterLappingSounds::CWaterLappingSounds() : CRoomAutoSoundPlayer(), + _value(0) { + _filename = "z#217.wav"; + _repeated = false; + _startSeconds = 0; +} + +void CWaterLappingSounds::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_filename, indent); + file->writeNumberLine(_repeated, indent); + file->writeNumberLine(_startSeconds, indent); + file->writeNumberLine(_value, indent); + + CRoomAutoSoundPlayer::save(file, indent); +} + +void CWaterLappingSounds::load(SimpleFile *file) { + file->readNumber(); + _filename = file->readString(); + _repeated = file->readNumber(); + _startSeconds = file->readNumber(); + _value = file->readNumber(); + + CRoomAutoSoundPlayer::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/sound/water_lapping_sounds.h b/engines/titanic/sound/water_lapping_sounds.h new file mode 100644 index 0000000000..2d0594b26b --- /dev/null +++ b/engines/titanic/sound/water_lapping_sounds.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_WATER_LAPPING_SOUNDS_H +#define TITANIC_WATER_LAPPING_SOUNDS_H + +#include "titanic/sound/room_auto_sound_player.h" + +namespace Titanic { + +class CWaterLappingSounds : public CRoomAutoSoundPlayer { + DECLARE_MESSAGE_MAP; +public: + int _value; +public: + CLASSDEF; + CWaterLappingSounds(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WATER_LAPPING_SOUNDS_H */ diff --git a/engines/titanic/sound/wave_file.cpp b/engines/titanic/sound/wave_file.cpp new file mode 100644 index 0000000000..8c00637d73 --- /dev/null +++ b/engines/titanic/sound/wave_file.cpp @@ -0,0 +1,101 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "audio/decoders/wave.h" +#include "common/memstream.h" +#include "titanic/sound/wave_file.h" +#include "titanic/sound/sound_manager.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +CWaveFile::CWaveFile() : _owner(nullptr), _stream(nullptr), + _soundType(Audio::Mixer::kPlainSoundType) { +} + +CWaveFile::CWaveFile(QSoundManager *owner) : _owner(owner), _stream(nullptr), + _soundType(Audio::Mixer::kPlainSoundType) { +} + +CWaveFile::~CWaveFile() { + if (_stream) { + _owner->soundFreed(_soundHandle); + delete _stream; + } +} + +int CWaveFile::fn1() { + // TODO + return 0; +} + +bool CWaveFile::loadSound(const CString &name) { + assert(!_stream); + + StdCWadFile file; + if (!file.open(name)) + return false; + + Common::SeekableReadStream *stream = file.readStream(); + _size = stream->size(); + _stream = Audio::makeWAVStream(stream->readStream(_size), DisposeAfterUse::YES); + _soundType = Audio::Mixer::kSFXSoundType; + + return true; +} + +bool CWaveFile::loadSpeech(CDialogueFile *dialogueFile, int speechIndex) { + DialogueResource *res = dialogueFile->openWaveEntry(speechIndex); + if (!res) + return false; + + byte *data = (byte *)malloc(res->_size); + dialogueFile->read(res, data, res->_size); + + _size = res->_size; + _stream = Audio::makeWAVStream(new Common::MemoryReadStream(data, _size, DisposeAfterUse::YES), + DisposeAfterUse::YES); + _soundType = Audio::Mixer::kSpeechSoundType; + + return true; +} + +bool CWaveFile::loadMusic(const CString &name) { + assert(!_stream); + + StdCWadFile file; + if (!file.open(name)) + return false; + + Common::SeekableReadStream *stream = file.readStream(); + _size = stream->size(); + _stream = Audio::makeWAVStream(stream->readStream(_size), DisposeAfterUse::YES); + _soundType = Audio::Mixer::kMusicSoundType; + + return true; +} + +uint CWaveFile::getFrequency() const { + return _stream->getRate(); +} + +} // End of namespace Titanic z diff --git a/engines/titanic/sound/wave_file.h b/engines/titanic/sound/wave_file.h new file mode 100644 index 0000000000..aede0c9328 --- /dev/null +++ b/engines/titanic/sound/wave_file.h @@ -0,0 +1,83 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_WAVE_FILE_H +#define TITANIC_WAVE_FILE_H + +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "titanic/support/string.h" +#include "titanic/true_talk/dialogue_file.h" + +namespace Titanic { + +class QSoundManager; + +class CWaveFile { +private: + uint _size; +public: + QSoundManager *_owner; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle _soundHandle; + Audio::Mixer::SoundType _soundType; +public: + CWaveFile(); + CWaveFile(QSoundManager *owner); + ~CWaveFile(); + + int fn1(); + + /** + * Return the size of the wave file + */ + uint size() const { return _size; } + + /** + * Tries to load the specified wave file sound + */ + bool loadSound(const CString &name); + + /** + * Tries to load speech from a specified dialogue file + */ + bool loadSpeech(CDialogueFile *dialogueFile, int speechIndex); + + /** + * Tries to load the specified music wave file + */ + bool loadMusic(const CString &name); + + /** + * Returns true if the wave file has data loaded + */ + bool isLoaded() const { return _stream != nullptr; } + + /** + * Return the frequency of the loaded wave file + */ + uint getFrequency() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_WAVE_FILE_H */ diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp new file mode 100644 index 0000000000..f09df38620 --- /dev/null +++ b/engines/titanic/star_control/base_star.cpp @@ -0,0 +1,118 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/base_star.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CBaseStarEntry::CBaseStarEntry() : _field0(0), _value(0.0) { + Common::fill(&_data[0], &_data[5], 0); +} + +void CBaseStarEntry::load(Common::SeekableReadStream &s) { + _field0 = s.readByte(); + _field1 = s.readByte(); + _field2 = s.readByte(); + _field3 = s.readByte(); + *((uint32 *)&_value) = s.readUint32LE(); // FIXME + _val._v1 = s.readUint32LE(); + _val._v2 = s.readUint32LE(); + _val._v3 = s.readUint32LE(); + + for (int idx = 0; idx < 5; ++idx) + _data[idx] = s.readUint32LE(); +} + +/*------------------------------------------------------------------------*/ + +CBaseStar::CBaseStar() : _minVal(0.0), _maxVal(1.0), _range(0.0) { +} + +void CBaseStar::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) { + // TODO +} + +void CBaseStar::clear() { + _data.clear(); +} + +void CBaseStar::initialize() { + _minVal = 9.9999998e10; + _maxVal = -9.9999998e10; + _sub4.initialize(); + + for (uint idx = 0; idx < _data.size(); ++idx) { + const CBaseStarEntry *entry = getDataPtr(idx); + _sub4.checkEntry(entry->_val); + + if (entry->_value < _minVal) + _minVal = entry->_value; + if (entry->_value > _maxVal) + _maxVal = entry->_value; + } + + _range = (_maxVal - _minVal) / 1.0; +} + +CBaseStarEntry *CBaseStar::getDataPtr(int index) { + return (index >= 0 && index < (int)_data.size()) ? &_data[index] : nullptr; +} + +void CBaseStar::loadData(Common::SeekableReadStream &s) { + uint headerId = s.readUint32LE(); + uint count = s.readUint32LE(); + if (headerId != 100 || count == 0) + error("Invalid star data"); + + // Initialize the data array + clear(); + _data.resize(count); + + // Iterate through reading the data for each entry + for (uint idx = 0; idx < count; ++idx) + _data[idx].load(s); +} + +void CBaseStar::loadData(const CString &resName) { + // Get a stream to read the data from the DAT file + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(resName); + assert(stream); + + // Load the stream + loadData(*stream); + delete stream; +} + +void CBaseStar::resetEntry(CBaseStarEntry &entry) { + entry._field0 = 0xFF; + entry._field1 = 0xFF; + entry._field2 = 0xFF; + entry._field3 = 0; + entry._val._v1 = 0; + entry._val._v2 = 0; + entry._val._v3 = 0; + for (int idx = 0; idx < 5; ++idx) + entry._data[idx] = 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h new file mode 100644 index 0000000000..cf5cbc72d2 --- /dev/null +++ b/engines/titanic/star_control/base_star.h @@ -0,0 +1,110 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB3_H +#define TITANIC_STAR_CONTROL_SUB3_H + +#include "titanic/support/simple_file.h" +#include "titanic/star_control/star_control_sub4.h" +#include "titanic/star_control/star_control_sub5.h" +#include "titanic/star_control/surface_area.h" + +namespace Titanic { + +class CStarControlSub12; + +struct CBaseStarEntry { + byte _field0; + byte _field1; + byte _field2; + byte _field3; + double _value; + CBaseStarVal _val; + uint _data[5]; + + CBaseStarEntry(); + void load(Common::SeekableReadStream &s); +}; + +class CBaseStar { +protected: + Common::Array<CBaseStarEntry> _data; + CStarControlSub4 _sub4; + double _minVal; + double _maxVal; + double _range; +protected: + /** + * Get a pointer to a data entry + */ + CBaseStarEntry *getDataPtr(int index); + + /** + * Load entry data from a passed stream + */ + void loadData(Common::SeekableReadStream &s); + + /** + * Load entry data from a specified resource + */ + void loadData(const CString &resName); + + /** + * Reset the data for an entry + */ + void resetEntry(CBaseStarEntry &entry); +public: + CBaseStar(); + virtual ~CBaseStar() {} + + /** + * Draw the item + */ + virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5); + + virtual bool loadYale(int v1) { return true; } + virtual bool proc4(int v1, int v2, int v3, int v4, int v5) { return false; } + virtual bool proc5(int v1) { return false; } + virtual bool loadStar() { return false; } + virtual bool proc7(int v1, int v2) { return true; } + + /** + * Load the item's data + */ + virtual void load(SimpleFile *file) {} + + /** + * Save the item's data + */ + virtual void save(SimpleFile *file, int indent) {} + + /** + * Clear allocated data + */ + void clear(); + + void initialize(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB3_H */ diff --git a/engines/titanic/star_control/dmatrix.cpp b/engines/titanic/star_control/dmatrix.cpp new file mode 100644 index 0000000000..70008054b6 --- /dev/null +++ b/engines/titanic/star_control/dmatrix.cpp @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/dmatrix.h" +#include "titanic/star_control/fmatrix.h" +#include "titanic/star_control/star_control_sub26.h" + +namespace Titanic { + +DMatrix *DMatrix::_static; + +DMatrix::DMatrix() : + _row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) { +} + +DMatrix::DMatrix(int mode, const FMatrix *src) { + assert(!mode); + + _row1._x = 1.0; + _row2._y = 1.0; + _row3._z = 1.0; + _frow1._x = src->_row1._x; + _frow1._y = src->_row1._y; + _frow1._z = src->_row1._z; + _frow2._x = src->_row2._x; + _frow2._y = src->_row2._y; + _frow2._z = src->_row2._z; +} + +DMatrix::DMatrix(int mode, double val) { + set(mode, val); +} + +void DMatrix::init() { + _static = nullptr; +} + +void DMatrix::deinit() { + delete _static; + _static = nullptr; +} + +void DMatrix::set(int mode, double amount) { + const double FACTOR = 0.0174532925199433; + double sinVal = sin(amount * FACTOR); + double cosVal = cos(amount * FACTOR); + + switch (mode) { + case 0: + _row1._x = 1.0; + _row2._y = cosVal; + _row2._z = sinVal; + _row3._y = -sinVal; + _row3._z = cosVal; + break; + + case 1: + _row1._x = cosVal; + _row1._z = sinVal; + _row2._y = 1.0; + _row3._x = -sinVal; + _row3._z = cosVal; + break; + + case 2: + _row1._x = cosVal; + _row1._y = sinVal; + _row2._x = -sinVal; + _row2._y = cosVal; + _row3._z = 1.0; + break; + + default: + break; + } +} + +void DMatrix::fn3(CStarControlSub26 *sub26) { + double v = sub26->fn1(); + v = (v < 0.0) ? 0.0 : 2.0 / v; + + error("TODO: DMatrix::fn3 %d", (int)v); +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/dmatrix.h b/engines/titanic/star_control/dmatrix.h new file mode 100644 index 0000000000..14f6bb0331 --- /dev/null +++ b/engines/titanic/star_control/dmatrix.h @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DMATRIX_H +#define TITANIC_DMATRIX_H + +#include "titanic/star_control/dvector.h" +#include "titanic/star_control/fvector.h" + +namespace Titanic { + +class FMatrix; +class CStarControlSub26; + +/** + * Double based matrix class. + * @remarks TODO: See if it can be merged with FMatrix + */ +class DMatrix { +private: + static DMatrix *_static; +public: + DVector _row1; + DVector _row2; + DVector _row3; + FVector _frow1; + FVector _frow2; +public: + static void init(); + static void deinit(); +public: + DMatrix(); + DMatrix(int mode, const FMatrix *src); + DMatrix(int mode, double val); + + /** + * Sets up data for the matrix + */ + void set(int mode, double amount); + + void fn3(CStarControlSub26 *sub26); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DMATRIX_H */ diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp new file mode 100644 index 0000000000..e4c5b15cb0 --- /dev/null +++ b/engines/titanic/star_control/dvector.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/dvector.h" +#include "common/algorithm.h" + +namespace Titanic { + +void DVector::fn3() { + double hyp = sqrt(_x * _x + _y * _y + _z * _z); + assert(hyp); + + _x *= 1.0 / hyp; + _y *= 1.0 / hyp; + _z *= 1.0 / hyp; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h new file mode 100644 index 0000000000..7aca407c1c --- /dev/null +++ b/engines/titanic/star_control/dvector.h @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DVECTOR_H +#define TITANIC_DVECTOR_H + +namespace Titanic { + +/** + * Double based vector class. + * @remarks TODO: See if it can be merged with FVector + */ +class DVector { +public: + double _x, _y, _z; +public: + DVector() : _x(0), _y(0), _z(0) {} + DVector(double x, double y, double z) : _x(x), _y(y), _z(z) {} + + void fn3(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DVECTOR_H */ diff --git a/engines/titanic/star_control/error_code.h b/engines/titanic/star_control/error_code.h new file mode 100644 index 0000000000..52b0fb9f9e --- /dev/null +++ b/engines/titanic/star_control/error_code.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ERROR_CODE_H +#define TITANIC_ERROR_CODE_H + +namespace Titanic { + +class CErrorCode { +private: + int _value; +public: + CErrorCode() : _value(0) {} + + /** + * Sets the error code + */ + void set() { _value = 1; } + + /** + * Gets the error code and resets it + */ + int get() { + int result = _value; + _value = 0; + return result; + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ERROR_CODE_H */ diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp new file mode 100644 index 0000000000..af15477d04 --- /dev/null +++ b/engines/titanic/star_control/fmatrix.cpp @@ -0,0 +1,136 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/fmatrix.h" + +namespace Titanic { + +FMatrix::FMatrix() : + _row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) { +} + +FMatrix::FMatrix(DMatrix *src) { + copyFrom(src); +} + +FMatrix::FMatrix(FMatrix *src) { + _row1 = src->_row1; + _row2 = src->_row2; + _row3 = src->_row3; +} + +void FMatrix::copyFrom(const DMatrix *src) { + // TODO +} + +void FMatrix::load(SimpleFile *file, int param) { + _row1._x = file->readFloat(); + _row1._y = file->readFloat(); + _row1._z = file->readFloat(); + _row2._x = file->readFloat(); + _row2._y = file->readFloat(); + _row2._z = file->readFloat(); + _row3._x = file->readFloat(); + _row3._y = file->readFloat(); + _row3._z = file->readFloat(); +} + +void FMatrix::save(SimpleFile *file, int indent) { + file->writeFloatLine(_row1._x, indent); + file->writeFloatLine(_row1._y, indent); + file->writeFloatLine(_row1._z, indent); + file->writeFloatLine(_row2._x, indent); + file->writeFloatLine(_row2._y, indent); + file->writeFloatLine(_row2._z, indent); + file->writeFloatLine(_row3._x, indent); + file->writeFloatLine(_row3._y, indent); + file->writeFloatLine(_row3._z, indent); +} + +void FMatrix::clear() { + _row1 = FVector(1.0, 0.0, 0.0); + _row2 = FVector(0.0, 1.0, 0.0); + _row3 = FVector(0.0, 0.0, 1.0); +} + +void FMatrix::set(FVector *row1, FVector *row2, FVector *row3) { + _row1 = *row1; + _row2 = *row2; + _row3 = *row3; +} + +void FMatrix::fn1(const FVector *v) { + _row3._x = v->_x; + + FVector tempVector; + _row3.fn1(&tempVector); + + _row2._x = tempVector._x; + _row2._y = tempVector._y; + _row2._z = tempVector._z; + + _row3.multiply(&tempVector, &_row2); + _row1._x = _row2._x; + _row1._y = _row2._y; + _row1._z = _row2._z; + _row1.fn3(); + + _row3.multiply(&tempVector, &_row1); + _row2._x = _row1._x; + _row2._y = _row1._y; + _row2._z = _row1._z; + _row2.fn3(); +} + +void FMatrix::fn2(FMatrix *m) { + double x1 = _row1._y * m->_row2._x + _row1._z * m->_row3._x + _row1._x * m->_row1._x; + double y1 = _row1._x * m->_row1._y + m->_row2._y * _row1._y + m->_row3._y * _row1._z; + double z1 = _row1._x * m->_row1._z + _row1._y * m->_row2._z + _row1._z * m->_row3._z; + double x2 = m->_row1._x * _row2._x + m->_row3._x * _row2._z + m->_row2._x * _row2._y; + double y2 = m->_row3._y * _row2._z + m->_row1._y * _row2._x + m->_row2._y * _row2._y; + double z2 = _row2._z * m->_row3._z + _row2._x * m->_row1._z + _row2._y * m->_row2._z; + double x3 = m->_row1._x * _row3._x + _row3._z * m->_row3._x + _row3._y * m->_row2._x; + double y3 = _row3._y * m->_row2._y + _row3._z * m->_row3._y + _row3._x * m->_row1._y; + double z3 = _row3._x * m->_row1._z + _row3._y * m->_row2._z + _row3._z * m->_row3._z; + + _row1 = FVector(x1, y1, z1); + _row2 = FVector(x2, y2, z2); + _row3 = FVector(x3, y3, z3); +} + +void FMatrix::fn3(FMatrix *m) { + double x1 = _row2._x * m->_row1._y + m->_row1._z * _row3._x + _row1._x * m->_row1._x; + double y1 = m->_row1._x * _row1._y + _row3._y * m->_row1._z + _row2._y * m->_row1._y; + double z1 = m->_row1._x * _row1._z + m->_row1._y * _row2._z + m->_row1._z * _row3._z; + double x2 = _row1._x * m->_row2._x + _row2._x * m->_row2._y + _row3._x * m->_row2._z; + double y2 = _row3._y * m->_row2._z + _row1._y * m->_row2._x + _row2._y * m->_row2._y; + double z2 = m->_row2._z * _row3._z + m->_row2._x * _row1._z + m->_row2._y * _row2._z; + double x3 = _row1._x * m->_row3._x + m->_row3._z * _row3._x + m->_row3._y * _row2._x; + double y3 = m->_row3._y * _row2._y + m->_row3._z * _row3._y + m->_row3._x * _row1._y; + double z3 = m->_row3._x * _row1._z + m->_row3._y * _row2._z + m->_row3._z * _row3._z; + + _row1 = FVector(x1, y1, z1); + _row2 = FVector(x2, y2, z2); + _row3 = FVector(x3, y3, z3); +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h new file mode 100644 index 0000000000..d7c4acfbdc --- /dev/null +++ b/engines/titanic/star_control/fmatrix.h @@ -0,0 +1,94 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FMATRIX_H +#define TITANIC_FMATRIX_H + +#include "titanic/support/simple_file.h" +#include "titanic/star_control/fvector.h" + +namespace Titanic { + +class DMatrix; + +/** + * Floating point matrix class. + * @remarks TODO: See if it can be merged with DMatrix + */ +class FMatrix { +private: + /** + * Copys data from a given source + */ + void copyFrom(const DMatrix *src); +public: + FVector _row1; + FVector _row2; + FVector _row3; +public: + FMatrix(); + FMatrix(DMatrix *src); + FMatrix(FMatrix *src); + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file, int param); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file, int indent); + + /** + * Clears the matrix + */ + void clear(); + + /** + * Sets the data for the matrix + */ + void set(FVector *row1, FVector *row2, FVector *row3); + + void fn1(const FVector *v); + + void fn2(FMatrix *m); + void fn3(FMatrix *m); + + /** + * Returns true if the passed matrix equals this one + */ + bool operator==(const FMatrix &src) { + return _row1 == src._row1 && _row2 == src._row2 && _row3 == src._row3; + } + + /** + * Returns true if the passed matrix does not equal this one + */ + bool operator!=(const FMatrix &src) { + return !operator==(src); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MATRIX3_H */ diff --git a/engines/titanic/star_control/fpoint.cpp b/engines/titanic/star_control/fpoint.cpp new file mode 100644 index 0000000000..f3d7008324 --- /dev/null +++ b/engines/titanic/star_control/fpoint.cpp @@ -0,0 +1,28 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/fpoint.h" + +namespace Titanic { + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/fpoint.h b/engines/titanic/star_control/fpoint.h new file mode 100644 index 0000000000..f2cef18ea5 --- /dev/null +++ b/engines/titanic/star_control/fpoint.h @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FPOINT_H +#define TITANIC_FPOINT_H + +namespace Titanic { + +/** + * Floating point Point class + */ +class FPoint { +public: + double _x, _y; +public: + FPoint() : _x(0), _y(0) {} + FPoint(double x, double y) : _x(x), _y(y) {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FPOINT_H */ diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp new file mode 100644 index 0000000000..aa99e8b4d1 --- /dev/null +++ b/engines/titanic/star_control/fvector.cpp @@ -0,0 +1,71 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/fvector.h" +#include "titanic/star_control/star_control_sub6.h" +#include "common/algorithm.h" +#include "common/textconsole.h" + +namespace Titanic { + +void FVector::fn1(FVector *v) { + v->_x = (ABS(_x - _y) < 0.00001 && ABS(_y - _z) < 0.00001 && + ABS(_x - _z) < 0.00001) ? -_x : _x; + v->_y = _y; + v->_z = _z; +} + +void FVector::multiply(FVector *dest, const FVector *src) { + dest->_x = (src->_z * _y) - (_z * src->_y); + dest->_y = (src->_x * _z) - (_x * src->_z); + dest->_z = (src->_y * _x) - (_y * src->_x); +} + +void FVector::fn3() { + double hyp = sqrt(_x * _x + _y * _y + _z * _z); + assert(hyp); + + _x *= 1.0 / hyp; + _y *= 1.0 / hyp; + _z *= 1.0 / hyp; +} + +double FVector::getDistance(const FVector *src) const { + double xd = src->_x - _x; + double yd = src->_y - _y; + double zd = src->_z - _z; + + return sqrt(xd * xd + yd * yd + zd * zd); +} + +void FVector::fn4(FVector *dest, const FVector *v1, const FVector *v2) { + FVector tempVector(v1->_x + v2->_x, v1->_y + v2->_y, v1->_z + v2->_z); + tempVector.fn3(); + + *dest = tempVector; +} + +void FVector::fn5(FVector *dest, const CStarControlSub6 *sub6) const { + error("TODO: FVector::fn5"); +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h new file mode 100644 index 0000000000..8e1ba47a3e --- /dev/null +++ b/engines/titanic/star_control/fvector.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FVECTOR_H +#define TITANIC_FVECTOR_H + +namespace Titanic { + +class CStarControlSub6; + +/** + * Floating point vector class. + * @remarks TODO: See if it can be merged with DVector + */ +class FVector { +public: + double _x, _y, _z; +public: + FVector() : _x(0), _y(0), _z(0) {} + FVector(double x, double y, double z) : _x(x), _y(y), _z(z) {} + + void fn1(FVector *v); + void multiply(FVector *dest, const FVector *src); + void fn3(); + + /** + * Returns the distance between a specified point and this one + */ + double getDistance(const FVector *src) const; + + static void fn4(FVector *dest, const FVector *v1, const FVector *v2); + void fn5(FVector *dest, const CStarControlSub6 *sub6) const; + + /** + * Returns true if the passed vector equals this one + */ + bool operator==(const FVector &src) const { + return _x != src._x || _y != src._y || _z != src._z; + } + + /** + * Returns true if the passed vector does not equal this one + */ + bool operator!=(const FVector &src) const { + return !operator==(src); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FVECTOR_H */ diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp new file mode 100644 index 0000000000..7ba160cd37 --- /dev/null +++ b/engines/titanic/star_control/star_control.cpp @@ -0,0 +1,148 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/screen_manager.h" +#include "titanic/star_control/star_control.h" +#include "titanic/star_control/dmatrix.h" +#include "titanic/star_control/error_code.h" +#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/star_control_sub12.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CStarControl, CGameObject) + ON_MESSAGE(MouseMoveMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(KeyCharMsg) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + +CStarControl::CStarControl() : _fieldBC(0), _field80B0(0), + _starRect(20, 10, 620, 350) { + CStarControlSub6::init(); + CStarControlSub12::init(); + DMatrix::init(); +} + +CStarControl::~CStarControl() { + CStarControlSub6::deinit(); + CStarControlSub12::deinit(); + DMatrix::deinit(); +} + +void CStarControl::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + _starField.save(file, indent); + _view.save(file, indent); + CGameObject::save(file, indent); +} + +void CStarControl::load(SimpleFile *file) { + int val = file->readNumber(); + + if (!val) { + _starField.load(file); + if (!_starField.initDocument()) + error("Couldn't initialise the StarField document"); + + _view.load(file, 0); + CScreenManager *screenManager = CScreenManager::setCurrent(); + if (!screenManager) + error("There's no screen manager during loading"); + + _view.setup(screenManager, &_starField, this); + _view.reset(); + + _fieldBC = 1; + } + + CGameObject::load(file); +} + +void CStarControl::draw(CScreenManager *screenManager) { + if (_visible) + _view.draw(screenManager); +} + +bool CStarControl::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_visible && _starRect.contains(msg->_mousePos)) { + _view.MouseButtonDownMsg(0, Point(msg->_mousePos.x - 20, + msg->_mousePos.y - 10)); + return true; + } else { + return false; + } +} + +bool CStarControl::MouseMoveMsg(CMouseMoveMsg *msg) { + if (_visible && _starRect.contains(msg->_mousePos)) { + _view.MouseMoveMsg(0, Point(msg->_mousePos.x - 20, + msg->_mousePos.y - 10)); + makeDirty(); + return true; + } else { + return false; + } +} + +bool CStarControl::KeyCharMsg(CKeyCharMsg *msg) { + if (_visible) + _view.KeyCharMsg(msg->_key); + + return false; +} + +bool CStarControl::FrameMsg(CFrameMsg *msg) { + if (_visible) { + Point pt = getMousePos(); + if (_starRect.contains(pt)) + _view.MouseMoveMsg(0, pt); + + newFrame(); + makeDirty(); + return true; + } else { + return false; + } +} + +void CStarControl::newFrame() { + // TODO +} + +void CStarControl::fn1(int action) { + // TODO +} + +bool CStarControl::fn4() { + return _starField.get6(); +} + +bool CStarControl::canSetStarDestination() const { + return _view.canSetStarDestination(); +} + +void CStarControl::starDestinationSet() { + _view.starDestinationSet(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control.h b/engines/titanic/star_control/star_control.h new file mode 100644 index 0000000000..c0561ce908 --- /dev/null +++ b/engines/titanic/star_control/star_control.h @@ -0,0 +1,85 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_H +#define TITANIC_STAR_CONTROL_H + +#include "titanic/core/game_object.h" +#include "titanic/star_control/star_field.h" +#include "titanic/star_control/star_view.h" + +namespace Titanic { + +class CStarControl : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseMoveMsg(CMouseMoveMsg *msg); + bool KeyCharMsg(CKeyCharMsg *msg); + bool FrameMsg(CFrameMsg *msg); +private: + int _fieldBC; + CStarField _starField; + CStarView _view; + Rect _starRect; + int _field80B0; +private: + /** + * Called for ever new game frame + */ + void newFrame(); +public: + CLASSDEF; + CStarControl(); + virtual ~CStarControl(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Allows the item to draw itself + */ + virtual void draw(CScreenManager *screenManager); + + void fn1(int action); + bool fn4(); + + /** + * Returns true if a star destination can be set + */ + bool canSetStarDestination() const; + + /** + * Called when a star destination is set + */ + void starDestinationSet(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_H */ diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp new file mode 100644 index 0000000000..5840495d34 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub12.cpp @@ -0,0 +1,283 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_control_sub21.h" +#include "titanic/star_control/star_control_sub22.h" + +namespace Titanic { + +FMatrix *CStarControlSub12::_matrix1; +FMatrix *CStarControlSub12::_matrix2; + +CStarControlSub12::CStarControlSub12(void *val1, const CStar20Data *data) : + _currentIndex(-1), _handlerP(nullptr), _field108(0), + _sub13(val1) { + setupHandler(data); +} + +CStarControlSub12::CStarControlSub12(CStarControlSub13 *src) : + _currentIndex(-1), _handlerP(nullptr), _field108(0), _sub13(src) { +} + +void CStarControlSub12::init() { + _matrix1 = nullptr; + _matrix2 = nullptr; +} + +void CStarControlSub12::deinit() { + delete _matrix1; + delete _matrix2; + _matrix1 = nullptr; + _matrix2 = nullptr; +} + +CStarControlSub12::~CStarControlSub12() { + deleteHandler(); +} + +void CStarControlSub12::proc2(const void *src) { + _sub13.copyFrom(src); +} + +void CStarControlSub12::proc3(const CStar20Data *src) { + _handlerP->copyFrom(src); +} + +void CStarControlSub12::setPosition(const FVector &v) { + if (!isLocked()) { + _sub13.setPosition(v); + set108(); + } +} + +void CStarControlSub12::proc5(const FVector &v) { + if (!isLocked()) + _sub13.fn11(v); +} + +void CStarControlSub12::proc6(int v) { + if (!isLocked()) + _sub13.setC(v); +} + +void CStarControlSub12::proc7(int v) { + if (!isLocked()) + _sub13.set10(v); +} + +void CStarControlSub12::proc8(int v) { + if (!isLocked()) + _sub13.set14(v); +} + +void CStarControlSub12::proc9(int v) { + if (!isLocked()) + _sub13.set18(v); +} + +void CStarControlSub12::proc10(int v) { + if (!isLocked()) + _sub13.set1C(v); +} + +void CStarControlSub12::proc11() { + if (!isLocked()) + _sub13.fn12(); +} + +void CStarControlSub12::proc12(double v1, double v2) { + if (!isLocked()) + _sub13.fn13(v1, v2); +} + +void CStarControlSub12::proc13(CStarControlSub13 *dest) { + *dest = _sub13; +} + +void CStarControlSub12::proc14(int v) { + FMatrix matrix; + _sub13.getMatrix(&matrix); + FVector vector = _sub13._position; + + _handlerP->proc9(&vector, v, &matrix); +} + +void CStarControlSub12::proc15(int v) { + if (!_matrix1) + _matrix1 = new FMatrix(); + if (!_matrix2) + _matrix2 = new FMatrix(); + + _sub13.getMatrix(_matrix1); + *_matrix2 = *_matrix1; + + FVector v1 = _sub13._position; + FVector v2 = _sub13._position; + CErrorCode errorCode; + _handlerP->proc11(errorCode, v2, _matrix2); + + if (v1 != v2) { + _sub13.setPosition(v2); + set108(); + } + + if (_matrix1 != _matrix2) { + _sub13.setMatrix(_matrix2); + } +} + +void CStarControlSub12::proc16() { + _handlerP->proc4(); +} + +void CStarControlSub12::proc17() { + _handlerP->proc5(); +} + +void CStarControlSub12::proc18() { + _handlerP->proc6(); +} + +void CStarControlSub12::proc19() { + _handlerP->proc7(); +} + +void CStarControlSub12::proc20(double v) { + if (!isLocked()) + _sub13.fn14(v); +} + +void CStarControlSub12::proc21(CStarControlSub6 &sub6) { + if (!isLocked()) { + _sub13.setPosition(sub6); + set108(); + } +} + +void CStarControlSub12::proc22(FMatrix &m) { + if (!isLocked()) + _sub13.fn15(m); +} + +CStarControlSub6 CStarControlSub12::proc23() { + return _sub13.getSub1(); +} + +CStarControlSub6 CStarControlSub12::proc24() { + return _sub13.getSub2(); +} + +double CStarControlSub12::proc25() const { + return _sub13._field10; +} + +double CStarControlSub12::proc26() const { + return _sub13._field14; +} + +int CStarControlSub12::proc27() const { + return _sub13._field24; +} + +FVector CStarControlSub12::proc28(int index, const void *v2) { + error("TODO: CStarControlSub12::proc28"); + return FVector(); +} + +FVector CStarControlSub12::proc29(const FVector &v) { + return _sub13.fn16(v); +} + +FVector CStarControlSub12::proc30(int index, const FVector &v) { + return _sub13.fn17(index, v); +} + +FVector CStarControlSub12::proc31(int index, const FVector &v) { + return _sub13.fn18(index, v); +} + +void CStarControlSub12::proc32(double v1, double v2) { + error("TODO: CStarControlSub12::proc32"); +} + +bool CStarControlSub12::setArrayVector(const FVector &v) { + if (_currentIndex >= 2) + return false; + + error("TODO: CStarControlSub12::setArrayVector"); +} + +bool CStarControlSub12::proc35() { + if (_currentIndex == -1) + return false; + + error("TODO: CStarControlSub12::proc35"); +} + +void CStarControlSub12::proc36(double *v1, double *v2, double *v3, double *v4) { + _sub13.fn19(v1, v2, v3, v4); +} + +void CStarControlSub12::load(SimpleFile *file, int param) { + _sub13.load(file, param); +} + +void CStarControlSub12::save(SimpleFile *file, int indent) { + _sub13.save(file, indent); +} + +bool CStarControlSub12::setupHandler(const CStar20Data *src) { + CStarControlSub20 *handler = nullptr; + + switch (_currentIndex) { + case -1: + handler = new CStarControlSub21(src); + break; + + case 0: + case 1: + case 2: + handler = new CStarControlSub22(src); + break; + + default: + break; + } + + if (handler) { + assert(!_handlerP); + _handlerP = handler; + return true; + } else { + return false; + } +} + +void CStarControlSub12::deleteHandler() { + if (_handlerP) { + delete _handlerP; + _handlerP = nullptr; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h new file mode 100644 index 0000000000..8da45df5c0 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub12.h @@ -0,0 +1,120 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB12_H +#define TITANIC_STAR_CONTROL_SUB12_H + +#include "titanic/support/simple_file.h" +#include "titanic/star_control/fmatrix.h" +#include "titanic/star_control/star_control_sub13.h" +#include "titanic/star_control/star_control_sub20.h" + +namespace Titanic { + +class CStarControlSub12 { +private: + static FMatrix *_matrix1; + static FMatrix *_matrix2; +private: + int _currentIndex; + FVector _array[3]; + CStarControlSub20 *_handlerP; + CStarControlSub13 _sub13; + int _field108; +private: + /** + * Set up a handler + */ + bool setupHandler(const CStar20Data *src); + + /** + * Deletes any previous handler + */ + void deleteHandler(); + + /** + * Return whether the handler is locked + */ + bool isLocked() { return _handlerP->isLocked(); } +public: + static void init(); + static void deinit(); +public: + CStarControlSub12(void *val1, const CStar20Data *data); + CStarControlSub12(CStarControlSub13 *src); + virtual ~CStarControlSub12(); + + virtual void proc2(const void *src); + virtual void proc3(const CStar20Data *src); + virtual void setPosition(const FVector &v); + virtual void proc5(const FVector &v); + virtual void proc6(int v); + virtual void proc7(int v); + virtual void proc8(int v); + virtual void proc9(int v); + virtual void proc10(int v); + virtual void proc11(); + virtual void proc12(double v1, double v2); + virtual void proc13(CStarControlSub13 *dest); + virtual void proc14(int v); + virtual void proc15(int v); + virtual void proc16(); + virtual void proc17(); + virtual void proc18(); + virtual void proc19(); + virtual void proc20(double v); + virtual void proc21(CStarControlSub6 &sub6); + virtual void proc22(FMatrix &m); + virtual CStarControlSub6 proc23(); + virtual CStarControlSub6 proc24(); + virtual double proc25() const; + virtual double proc26() const; + virtual int proc27() const; + virtual FVector proc28(int index, const void *v2); + virtual FVector proc29(const FVector &v); + virtual FVector proc30(int index, const FVector &v); + virtual FVector proc31(int index, const FVector &v); + virtual void proc32(double v1, double v2); + virtual int getCurrentIndex() const { return _currentIndex; } + virtual bool setArrayVector(const FVector &v); + virtual bool proc35(); + virtual void proc36(double *v1, double *v2, double *v3, double *v4); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + + bool is108() const { return _field108; } + void set108() { _field108 = true; } + void reset108() { _field108 = false; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB12_H */ diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp new file mode 100644 index 0000000000..c721b395c6 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub13.cpp @@ -0,0 +1,237 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub13.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CStarControlSub13::CStarControlSub13(void *src) : + _fieldC0(0), _fieldC4(0), _fieldC8(0), _fieldCC(0), _fieldD0(0) { + if (src) { + setup(src); + } else { + _fieldC = 0; + _field10 = 0x44480000; + _field14 = 0x461C4000; + _field18 = 0x41A00000; + _field1C = 0x41A00000; + _width = 600; + _height = 340; + _field24 = 0; + } + + _fieldD4 = 0; +} + +CStarControlSub13::CStarControlSub13(CStarControlSub13 *src) : + _matrix(&src->_matrix), _sub1(&src->_sub1), _sub2(&src->_sub2) { + _position = src->_position; + _fieldC = src->_fieldC; + _field10 = src->_field10; + _field14 = src->_field14; + _field18 = src->_field18; + _field1C = src->_field1C; + _width = src->_width; + _height = src->_height; + + _fieldCC = src->_fieldCC; + _fieldD0 = src->_fieldD0; + _fieldC0 = src->_fieldC0; + _fieldC4 = src->_fieldC4; + _fieldC8 = src->_fieldC8; + _field24 = src->_field24; + + _valArray[0] = src->_valArray[0]; + _valArray[2] = src->_valArray[2]; + _valArray[3] = src->_valArray[3]; + _fieldD4 = 0; +} + +void CStarControlSub13::setup(void *ptr) { + // TODO +} + +void CStarControlSub13::copyFrom(const void *src) { + if (!src) + return; +/* + _field0 = src->_field0; + _field4 = src->_field4; + _field8 = src->_field8; + _fieldC = src->_field18; + _field10 = src->_field1C; + */ +} + +void CStarControlSub13::load(SimpleFile *file, int param) { + _position._x = file->readFloat(); + _position._y = file->readFloat(); + _position._z = file->readFloat(); + _fieldC = file->readFloat(); + _field10 = file->readFloat(); + _field14 = file->readFloat(); + _field18 = file->readFloat(); + _field1C = file->readFloat(); + + int widthHeight = file->readNumber(); + _width = widthHeight & 0xff; + _height = _width >> 16; + _field24 = file->readNumber(); + + for (int idx = 0; idx < 5; ++idx) + _valArray[idx] = file->readFloat(); + + _matrix.load(file, param); + _fieldD4 = 0; +} + +void CStarControlSub13::save(SimpleFile *file, int indent) { + file->writeFloatLine(_position._x, indent); + file->writeFloatLine(_position._y, indent); + file->writeFloatLine(_position._z, indent); + file->writeFloatLine(_fieldC, indent); + file->writeFloatLine(_field10, indent); + file->writeFloatLine(_field14, indent); + file->writeFloatLine(_field18, indent); + file->writeFloatLine(_field1C, indent); + file->writeFloatLine(_width | (_height << 16), indent); + + for (int idx = 0; idx < 5; ++idx) + file->writeFloatLine(_valArray[idx], indent); + + _matrix.save(file, indent); +} + +void CStarControlSub13::setPosition(const FVector &v) { + _position = v; + _fieldD4 = 0; +} + +void CStarControlSub13::setPosition(const CStarControlSub6 &sub6) { + FVector vector; + _position.fn5(&vector, &sub6); + _position = sub6._matrix._row1; + _fieldD4 = 0; +} + +void CStarControlSub13::setMatrix(const FMatrix &m) { + _matrix = m; + _fieldD4 = 0; +} + +void CStarControlSub13::fn11(const FVector &v) { + _matrix.fn1(&v); + _fieldD4 = 0; +} + +void CStarControlSub13::setC(int v) { + _fieldC = v; + _fieldD4 = 0; +} + +void CStarControlSub13::set10(int v) { + _field10 = v; + _fieldD4 = 0; +} + +void CStarControlSub13::set14(int v) { + _field10 = v; +} + +void CStarControlSub13::set18(int v) { + _field18 = v; + _fieldD4 = 0; +} + +void CStarControlSub13::set1C(int v) { + _field1C = v; + _fieldD4 = 0; +} + +void CStarControlSub13::fn12() { + _matrix.clear(); + error("TODO: CStarControlSub13::fn12"); +} + +void CStarControlSub13::fn13(double v1, double v2) { + if (v1 == 0.0) { + _valArray[0] = v2; + _valArray[1] = -v2; + } else { + _valArray[3] = v2; + _valArray[4] = -v2; + } + + _valArray[2] = 0.0; + _field24 = v2 ? 2 : 0; +} + +void CStarControlSub13::fn14(double v) { + error("TODO: CStarControlSub13::fn14"); +} + +void CStarControlSub13::fn15(FMatrix &matrix) { + _matrix.fn3(&matrix); + _fieldD4 = 0; +} + +CStarControlSub6 CStarControlSub13::getSub1() { + if (!_fieldD4) + reset(); + + return _sub1; +} + +CStarControlSub6 CStarControlSub13::getSub2() { + if (!_fieldD4) + reset(); + + return _sub2; +} + +FVector CStarControlSub13::fn16(const FVector &v) { + error("TODO: CStarControlSub13::fn16"); +} + +FVector CStarControlSub13::fn17(int index, const FVector &v) { + error("TODO: CStarControlSub13::fn17"); +} + +FVector CStarControlSub13::fn18(int index, const FVector &v) { + error("TODO: CStarControlSub13::fn17"); +} + +void CStarControlSub13::fn19(double *v1, double *v2, double *v3, double *v4) { + error("TODO: CStarControlSub13::fn19"); +} + +void CStarControlSub13::reset() { + const double FACTOR = 3.1415927 * 0.0055555557; + error("TODO: CStarControlSub13::reset"); +} + +void CStarControlSub13::getMatrix(FMatrix *matrix) { + *matrix = _matrix; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub13.h b/engines/titanic/star_control/star_control_sub13.h new file mode 100644 index 0000000000..2f0b479cec --- /dev/null +++ b/engines/titanic/star_control/star_control_sub13.h @@ -0,0 +1,115 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB13_H +#define TITANIC_STAR_CONTROL_SUB13_H + +#include "titanic/support/simple_file.h" +#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/fmatrix.h" + +namespace Titanic { + +class CStarControlSub13 { +private: + double _fieldC; + double _field18; + double _field1C; + int _width; + int _height; + double _valArray[5]; + FMatrix _matrix; + CStarControlSub6 _sub1; + CStarControlSub6 _sub2; + double _fieldC0; + double _fieldC4; + int _fieldC8; + int _fieldCC; + double _fieldD0; + int _fieldD4; +private: + void setup(void *ptr); + + void reset(); +public: + FVector _position; + double _field10; + double _field14; + int _field24; +public: + CStarControlSub13(void *ptr); + CStarControlSub13(CStarControlSub13 *src); + + void copyFrom(const void *src); + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file, int param); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file, int indent); + + /** + * Sets the position + */ + void setPosition(const FVector &v); + + /** + * Sets the position + */ + void setPosition(const CStarControlSub6 &sub6); + + /** + * Sets the matrix + */ + void setMatrix(const FMatrix &m); + + void fn11(const FVector &v); + void fn12(); + void fn13(double v1, double v2); + void fn14(double v); + void fn15(FMatrix &matrix); + CStarControlSub6 getSub1(); + CStarControlSub6 getSub2(); + FVector fn16(const FVector &v); + FVector fn17(int index, const FVector &v); + FVector fn18(int index, const FVector &v); + void fn19(double *v1, double *v2, double *v3, double *v4); + + /** + * Makes a copy of the instance's matrix into the passed matrix + */ + void getMatrix(FMatrix *matrix); + + void setC(int v); + void set10(int v); + void set14(int v); + void set18(int v); + void set1C(int v); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB13_H */ diff --git a/engines/titanic/star_control/star_control_sub2.cpp b/engines/titanic/star_control/star_control_sub2.cpp new file mode 100644 index 0000000000..fcbb70cbcb --- /dev/null +++ b/engines/titanic/star_control/star_control_sub2.cpp @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub2.h" + +namespace Titanic { + +bool CStarControlSub2::proc3(int v1) { + clear(); + // TODO + return true; +} + +bool CStarControlSub2::proc4(int v1, int v2, int v3, int v4, int v5) { + // TODO + return true; +} + +bool CStarControlSub2::loadStar() { + // TODO + return true; +} + +bool CStarControlSub2::proc7(int v1, int v2) { + // TODO + return true; +} + +bool CStarControlSub2::setup() { + // TODO + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub2.h b/engines/titanic/star_control/star_control_sub2.h new file mode 100644 index 0000000000..cd7781548f --- /dev/null +++ b/engines/titanic/star_control/star_control_sub2.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB2_H +#define TITANIC_STAR_CONTROL_SUB2_H + +#include "titanic/star_control/base_star.h" + +namespace Titanic { + +class CStarControlSub2: public CBaseStar { +public: + virtual ~CStarControlSub2() {} + + virtual bool proc3(int v1); + virtual bool proc4(int v1, int v2, int v3, int v4, int v5); + virtual bool loadStar(); + virtual bool proc7(int v1, int v2); + + /** + * Setup the control + */ + bool setup(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB2_H */ diff --git a/engines/titanic/star_control/star_control_sub20.cpp b/engines/titanic/star_control/star_control_sub20.cpp new file mode 100644 index 0000000000..5c6c243eaa --- /dev/null +++ b/engines/titanic/star_control/star_control_sub20.cpp @@ -0,0 +1,144 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub20.h" +#include "common/textconsole.h" + +namespace Titanic { + +CStarControlSub20::CStarControlSub20(const CStar20Data *src) { + _lockCounter = 0; + _dataP = nullptr; + + if (src) { + copyFrom(src); + } else { + _field0 = 0.0; + _field4 = 0.0; + _field8 = 20.0; + _fieldC = 0.0; + _field10 = 50000.0; + _field14 = 1.0; + _field18 = 1.0; + _field1C = 0.0; + } +} + +CStarControlSub20::~CStarControlSub20() { + clear(); +} + +void CStarControlSub20::copyFrom(const CStar20Data *src) { + *((CStar20Data *)this) = *src; +} + +void CStarControlSub20::copyTo(CStar20Data *dest) { + *dest = *((CStar20Data *)this); +} + +void CStarControlSub20::proc4() { + if (!isLocked() && _field0 < _field10) { + _field4 += _field0; + if (_field8 == _field4) + _field0 -= _field4; + else + _field0 += _field4; + } +} + +void CStarControlSub20::proc5() { + if (!isLocked()) { + _field4 -= _field8; + if (_field4 == _field0) + _field0 += _field4; + else + _field0 -= _field4; + + if (_field4 < 0.0) + _field4 = 0.0; + } +} + +void CStarControlSub20::proc6() { + if (!isLocked()) + _field0 = _field10; +} + +void CStarControlSub20::proc7() { + if (!isLocked()) { + _field0 = 0.0; + _field4 = 0.0; + } +} + +void CStarControlSub20::proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m) { + if (_field0 > 0.0) { + warning("TODO: CStarControlSub20::proc11"); + } +} + +void CStarControlSub20::setData(void *data) { + clear(); + _dataP = (byte *)data; +} + +void CStarControlSub20::clear() { + if (_dataP) { + delete _dataP; + _dataP = nullptr; + } +} + +void CStarControlSub20::load(SimpleFile *file, int val) { + if (!val) { + _field0 = file->readFloat(); + _field4 = file->readFloat(); + _field8 = file->readFloat(); + _fieldC = file->readFloat(); + _field10 = file->readFloat(); + _field14 = file->readFloat(); + _field18 = file->readFloat(); + _field1C = file->readFloat(); + } +} + +void CStarControlSub20::save(SimpleFile *file, int indent) { + file->writeFloatLine(_field0, indent); + file->writeFloatLine(_field4, indent); + file->writeFloatLine(_field8, indent); + file->writeFloatLine(_fieldC, indent); + file->writeFloatLine(_field10, indent); + file->writeFloatLine(_field14, indent); + file->writeFloatLine(_field18, indent); + file->writeFloatLine(_field1C, indent); +} + +void CStarControlSub20::incLockCount() { + ++_lockCounter; +} + +void CStarControlSub20::decLockCount() { + if (_lockCounter > 0) + --_lockCounter; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub20.h b/engines/titanic/star_control/star_control_sub20.h new file mode 100644 index 0000000000..9dbabbb7f1 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub20.h @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB20_H +#define TITANIC_STAR_CONTROL_SUB20_H + +#include "titanic/support/simple_file.h" +#include "titanic/star_control/error_code.h" +#include "titanic/star_control/fmatrix.h" + +namespace Titanic { + +struct CStar20Data { + double _field0; + double _field4; + double _field8; + double _fieldC; + double _field10; + double _field14; + double _field18; + double _field1C; +}; + +class CStarControlSub20 : public CStar20Data { +public: + int _lockCounter; + byte *_dataP; +public: + CStarControlSub20(const CStar20Data *src); + virtual ~CStarControlSub20(); + + virtual void copyFrom(const CStar20Data *src); + virtual void copyTo(CStar20Data *dest); + virtual void proc4(); + virtual void proc5(); + virtual void proc6(); + virtual void proc7(); + virtual void proc8() {} + virtual void proc9(FVector *v, int v2, FMatrix *matrix) {} + virtual void proc10() {} + virtual void proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m); + + /** + * Set the data + */ + virtual void setData(void *data); + + /** + * Clear the class + */ + virtual void clear(); + + /** + * Load the class + */ + virtual void load(SimpleFile *file, int val = 0); + + /** + * Save the class + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Increment tthe lock counter + */ + void incLockCount(); + + /** + * Decrement the lock counter + */ + void decLockCount(); + + /** + * Returns true if the lock counter is non-zero + */ + bool isLocked() const { return _lockCounter > 0; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB20_H */ diff --git a/engines/titanic/star_control/star_control_sub21.cpp b/engines/titanic/star_control/star_control_sub21.cpp new file mode 100644 index 0000000000..1730244184 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub21.cpp @@ -0,0 +1,32 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub21.h" +#include "common/textconsole.h" + +namespace Titanic { + +CStarControlSub21::CStarControlSub21(const CStar20Data *src) : + CStarControlSub20(src), _sub24() { +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub21.h b/engines/titanic/star_control/star_control_sub21.h new file mode 100644 index 0000000000..5febda0ebb --- /dev/null +++ b/engines/titanic/star_control/star_control_sub21.h @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB21_H +#define TITANIC_STAR_CONTROL_SUB21_H + +#include "titanic/star_control/star_control_sub20.h" +#include "titanic/star_control/star_control_sub24.h" + +namespace Titanic { + +class CStarControlSub21 : public CStarControlSub20 { +private: + CStarControlSub24 _sub24; +public: + CStarControlSub21(const CStar20Data *src); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB21_H */ diff --git a/engines/titanic/star_control/star_control_sub22.cpp b/engines/titanic/star_control/star_control_sub22.cpp new file mode 100644 index 0000000000..b06731b6d2 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub22.cpp @@ -0,0 +1,32 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub22.h" +#include "common/textconsole.h" + +namespace Titanic { + +CStarControlSub22::CStarControlSub22(const CStar20Data *src) : + CStarControlSub20(src), _sub27() { +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub22.h b/engines/titanic/star_control/star_control_sub22.h new file mode 100644 index 0000000000..88a114f8c3 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub22.h @@ -0,0 +1,40 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB22_H +#define TITANIC_STAR_CONTROL_SUB22_H + +#include "titanic/star_control/star_control_sub20.h" +#include "titanic/star_control/star_control_sub27.h" + +namespace Titanic { + +class CStarControlSub22 : public CStarControlSub20 { +private: + CStarControlSub27 _sub27; +public: + CStarControlSub22(const CStar20Data *src); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB22_H */ diff --git a/engines/titanic/star_control/star_control_sub23.cpp b/engines/titanic/star_control/star_control_sub23.cpp new file mode 100644 index 0000000000..b009cbc35b --- /dev/null +++ b/engines/titanic/star_control/star_control_sub23.cpp @@ -0,0 +1,28 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub23.h" +#include "common/textconsole.h" + +namespace Titanic { + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub23.h b/engines/titanic/star_control/star_control_sub23.h new file mode 100644 index 0000000000..136401e329 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub23.h @@ -0,0 +1,33 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB23_H +#define TITANIC_STAR_CONTROL_SUB23_H + +namespace Titanic { + +class CStarControlSub23 { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB23_H */ diff --git a/engines/titanic/star_control/star_control_sub24.cpp b/engines/titanic/star_control/star_control_sub24.cpp new file mode 100644 index 0000000000..6f17eb7193 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub24.cpp @@ -0,0 +1,29 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub24.h" +#include "common/textconsole.h" + +namespace Titanic { + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub24.h b/engines/titanic/star_control/star_control_sub24.h new file mode 100644 index 0000000000..e0970fc1de --- /dev/null +++ b/engines/titanic/star_control/star_control_sub24.h @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB24_H +#define TITANIC_STAR_CONTROL_SUB24_H + +#include "titanic/star_control/star_control_sub23.h" + +namespace Titanic { + +class CStarControlSub24 : public CStarControlSub23 { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB24_H */ diff --git a/engines/titanic/star_control/star_control_sub25.cpp b/engines/titanic/star_control/star_control_sub25.cpp new file mode 100644 index 0000000000..f91c75af6a --- /dev/null +++ b/engines/titanic/star_control/star_control_sub25.cpp @@ -0,0 +1,28 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub25.h" +#include "common/textconsole.h" + +namespace Titanic { + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub25.h b/engines/titanic/star_control/star_control_sub25.h new file mode 100644 index 0000000000..e943782e37 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub25.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB25_H +#define TITANIC_STAR_CONTROL_SUB25_H + +#include "titanic/star_control/fmatrix.h" +#include "titanic/star_control/star_control_sub26.h" + +namespace Titanic { + +class CStarControlSub25 { +public: + FMatrix _matrix1; + FMatrix _matrix2; + CStarControlSub26 _sub1; + CStarControlSub26 _sub2; +public: + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB25_H */ diff --git a/engines/titanic/star_control/star_control_sub26.cpp b/engines/titanic/star_control/star_control_sub26.cpp new file mode 100644 index 0000000000..89ff93c347 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub26.cpp @@ -0,0 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub26.h" +#include "common/textconsole.h" + +namespace Titanic { + +double CStarControlSub26::fn1() const { + return _sub._v1 * _sub._v1 + _sub._v2 * _sub._v2 + + _sub._v3 * _sub._v3 + _field0 * _field0; +} + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub26.h b/engines/titanic/star_control/star_control_sub26.h new file mode 100644 index 0000000000..4054a2ba6e --- /dev/null +++ b/engines/titanic/star_control/star_control_sub26.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB26_H +#define TITANIC_STAR_CONTROL_SUB26_H + +namespace Titanic { + +class CStarControlSub26 { + struct Sub { + double _v1; + double _v2; + double _v3; + + Sub() : _v1(0.0), _v2(0.0), _v3(0.0) {} + }; +public: + double _field0; + Sub _sub; +public: + CStarControlSub26() : _field0(1.0) {} + + double fn1() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB26_H */ diff --git a/engines/titanic/star_control/star_control_sub27.cpp b/engines/titanic/star_control/star_control_sub27.cpp new file mode 100644 index 0000000000..6f17eb7193 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub27.cpp @@ -0,0 +1,29 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub24.h" +#include "common/textconsole.h" + +namespace Titanic { + + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub27.h b/engines/titanic/star_control/star_control_sub27.h new file mode 100644 index 0000000000..01782b69ca --- /dev/null +++ b/engines/titanic/star_control/star_control_sub27.h @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB27_H +#define TITANIC_STAR_CONTROL_SUB27_H + +#include "titanic/star_control/star_control_sub23.h" + +namespace Titanic { + +class CStarControlSub27 : public CStarControlSub23 { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB27_H */ diff --git a/engines/titanic/star_control/star_control_sub4.cpp b/engines/titanic/star_control/star_control_sub4.cpp new file mode 100644 index 0000000000..f765acbbc1 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub4.cpp @@ -0,0 +1,45 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/algorithm.h" +#include "titanic/star_control/star_control_sub4.h" + +namespace Titanic { + +CStarControlSub4::CStarControlSub4() { +} + +void CStarControlSub4::initialize() { + _min._v1 = _min._v2 = _min._v3 = 9.9999994e27; + _max._v1 = _max._v2 = _max._v3 = -9.9999994e27; +} + +void CStarControlSub4::checkEntry(const CBaseStarVal &val) { + _min._v1 = MIN(_min._v1, val._v1); + _min._v2 = MIN(_min._v2, val._v2); + _min._v3 = MIN(_min._v3, val._v3); + _max._v1 = MAX(_max._v1, val._v1); + _max._v2 = MAX(_max._v2, val._v2); + _max._v3 = MAX(_max._v3, val._v3); +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub4.h b/engines/titanic/star_control/star_control_sub4.h new file mode 100644 index 0000000000..f0fcfaf7f4 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub4.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB4_H +#define TITANIC_STAR_CONTROL_SUB4_H + +namespace Titanic { + +struct CBaseStarVal { + double _v1, _v2, _v3; + CBaseStarVal() : _v1(0), _v2(0), _v3(0) {} +}; + +class CStarControlSub4 { +private: + CBaseStarVal _min; + CBaseStarVal _max; +public: + CStarControlSub4(); + + void initialize(); + + void checkEntry(const CBaseStarVal &val); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB4_H */ diff --git a/engines/titanic/star_control/star_control_sub5.cpp b/engines/titanic/star_control/star_control_sub5.cpp new file mode 100644 index 0000000000..e2899220c8 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub5.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub5.h" + +namespace Titanic { + +CStarControlSub5::CStarControlSub5() : + _field4(1), _field78AC(0), _field78B0(0) { +} + +bool CStarControlSub5::setup() { + // TODO + return true; +} + +void CStarControlSub5::proc2() { + // TODO +} + +void CStarControlSub5::proc3(CErrorCode *errorCode) { + // TODO +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub5.h b/engines/titanic/star_control/star_control_sub5.h new file mode 100644 index 0000000000..ce92ef1135 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub5.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB5_H +#define TITANIC_STAR_CONTROL_SUB5_H + +#include "titanic/star_control/star_control_sub6.h" +#include "titanic/star_control/error_code.h" + +namespace Titanic { + +class CStarControlSub5 { + struct SubEntry { + int _field0; + int _field4; + int _field8; + int _fieldC; + }; +private: + int _field4; + SubEntry _array[5]; + CStarControlSub6 _sub1, _sub2; + int _field7914; + int _field78AC; + int _field78B0; +public: + CStarControlSub5(); + virtual ~CStarControlSub5() {} + + virtual bool setup(); + virtual void proc2(); + virtual void proc3(CErrorCode *errorCode); + + int get4() const { return _field4; } + void set4(int val) { _field4 = val; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB5_H */ diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/star_control_sub6.cpp new file mode 100644 index 0000000000..a5a1d81aa8 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub6.cpp @@ -0,0 +1,115 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub6.h" + +namespace Titanic { + +CStarControlSub6 *CStarControlSub6::_static; + +CStarControlSub6::CStarControlSub6() { + clear(); +} + +CStarControlSub6::CStarControlSub6(int mode, double val) { + set(mode, val); +} + +CStarControlSub6::CStarControlSub6(const CStarControlSub6 *src) { + copyFrom(src); +} + +void CStarControlSub6::init() { + _static = nullptr; +} + +void CStarControlSub6::deinit() { + delete _static; + _static = nullptr; +} + +void CStarControlSub6::clear() { + _matrix.clear(); + _field24 = 0; + _field28 = 0; + _field2C = 0; +} + +void CStarControlSub6::set(int mode, double amount) { + const double ROTATION = 3.1415927 * 0.0055555557; + double sinVal = sin(amount * ROTATION); + double cosVal = cos(amount * ROTATION); + + switch (mode) { + case 0: + _matrix._row1._x = 1.0; + _matrix._row1._y = 0.0; + _matrix._row1._z = 0.0; + _matrix._row2._x = 0.0; + _matrix._row2._y = cosVal; + _matrix._row2._z = sinVal; + _matrix._row3._x = 0.0; + _matrix._row3._y = -sinVal; + _matrix._row3._z = cosVal; + break; + + case 1: + _matrix._row1._x = cosVal; + _matrix._row1._y = 0.0; + _matrix._row1._z = sinVal; + _matrix._row2._x = 0.0; + _matrix._row2._y = 1.0; + _matrix._row2._z = 0.0; + _matrix._row3._x = -sinVal; + _matrix._row3._y = 0.0; + _matrix._row3._z = sinVal; + break; + + case 2: + _matrix._row1._x = cosVal; + _matrix._row1._y = sinVal; + _matrix._row1._z = 0.0; + _matrix._row2._x = -sinVal; + _matrix._row2._y = cosVal; + _matrix._row2._z = 0.0; + _matrix._row3._x = 0.0; + _matrix._row3._y = 0.0; + _matrix._row3._z = 1.0; + break; + + default: + break; + } + + _field24 = 0.0; + _field28 = 0.0; + _field2C = 0.0; +} + +void CStarControlSub6::copyFrom(const CStarControlSub6 *src) { + _matrix = src->_matrix; + _field24 = src->_field24; + _field28 = src->_field28; + _field2C = src->_field2C; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub6.h b/engines/titanic/star_control/star_control_sub6.h new file mode 100644 index 0000000000..118c7c7f10 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub6.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB6_H +#define TITANIC_STAR_CONTROL_SUB6_H + +#include "titanic/star_control/fmatrix.h" + +namespace Titanic { + +class CStarControlSub6 { +private: + int _field24; + int _field28; + int _field2C; +private: + static CStarControlSub6 *_static; +public: + static void init(); + static void deinit(); +public: + FMatrix _matrix; +public: + CStarControlSub6(); + CStarControlSub6(int mode, double amount); + CStarControlSub6(const CStarControlSub6 *src); + + /** + * Clear the item + */ + void clear(); + + /** + * Sets the default data + */ + void set(int mode, double val); + + void copyFrom(const CStarControlSub6 *src); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB6_H */ diff --git a/engines/titanic/star_control/star_control_sub7.cpp b/engines/titanic/star_control/star_control_sub7.cpp new file mode 100644 index 0000000000..b33f8be582 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub7.cpp @@ -0,0 +1,36 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub7.h" + +namespace Titanic { + +void CStarControlSub7::proc2(int v1, int v2, int v3) { + // TODO +} + +bool CStarControlSub7::proc5(int v1) { + // TODO + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub7.h b/engines/titanic/star_control/star_control_sub7.h new file mode 100644 index 0000000000..b73124ddd7 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub7.h @@ -0,0 +1,39 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB7_H +#define TITANIC_STAR_CONTROL_SUB7_H + +#include "titanic/star_control/base_star.h" +namespace Titanic { + +class CStarControlSub7 : public CBaseStar { +public: + virtual ~CStarControlSub7() { clear(); } + + virtual void proc2(int v1, int v2, int v3); + virtual bool proc5(int v1); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB7_H */ diff --git a/engines/titanic/star_control/star_control_sub8.cpp b/engines/titanic/star_control/star_control_sub8.cpp new file mode 100644 index 0000000000..cdb249b663 --- /dev/null +++ b/engines/titanic/star_control/star_control_sub8.cpp @@ -0,0 +1,31 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_control_sub8.h" + +namespace Titanic { + +CStarControlSub8::CStarControlSub8() : + _field0(0), _field4(0), _field8(-1), _fieldC(-1) { +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub8.h b/engines/titanic/star_control/star_control_sub8.h new file mode 100644 index 0000000000..6d8d1f0c7d --- /dev/null +++ b/engines/titanic/star_control/star_control_sub8.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CONTROL_SUB8_H +#define TITANIC_STAR_CONTROL_SUB8_H + +#include "titanic/support/simple_file.h" + +namespace Titanic { + +class CStarControlSub8 { + struct StructEntry { + int _field0; + int _field4; + int _field8; + int _fieldC; + }; +private: + int _field0; + int _field4; + int _fieldC; + StructEntry _array[3]; +public: + int _field8; +public: + CStarControlSub8(); + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file) {} + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file, int indent) {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB8_H */ diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp new file mode 100644 index 0000000000..c50e8466ec --- /dev/null +++ b/engines/titanic/star_control/star_field.cpp @@ -0,0 +1,130 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_field.h" +#include "titanic/star_control/surface_area.h" + +namespace Titanic { + +CStarField::CStarField() : _val1(0), _val2(0), _val3(0), _val4(true), + _val5(0), _val6(false) { +} + +void CStarField::load(SimpleFile *file) { + _sub7.load(file); + _sub8.load(file); + _val1 = file->readNumber(); + _val2 = file->readNumber(); + _val3 = file->readNumber(); + _val4 = file->readNumber(); + _val6 = file->readNumber(); +} + +void CStarField::save(SimpleFile *file, int indent) { + _sub7.save(file, indent); + _sub8.save(file, indent); + file->writeNumberLine(_val1, indent); + file->writeNumberLine(_val2, indent); + file->writeNumberLine(_val3, indent); + file->writeNumberLine(_val4, indent); + file->writeNumberLine(_val6, indent); +} + +bool CStarField::initDocument() { + bool valid = setup() && _points1.initialize(); + if (valid) + valid = _sub5.setup(); + if (valid) + valid = _points1.initialize(); + if (valid) + valid = _points2.initialize(); + + return valid; +} + +void CStarField::render(CVideoSurface *surface, CStarControlSub12 *sub12) { + CSurfaceArea surfaceArea(surface); + draw(&surfaceArea, sub12, &_sub5); + + + // TODO +} + +int CStarField::get1() const { + return _val1; +} + +void CStarField::set1(int val) { + _val1 = val; +} + +int CStarField::get2() const { + return _val2; +} + +void CStarField::set2(int val) { + _val2 = val; +} + +int CStarField::get54() const { + return _sub5.get4(); +} + +void CStarField::set54(int val) { + _sub5.set4(val); +} + +int CStarField::get3() const { + return _val3; +} + +void CStarField::set3(int val) { + _val3 = val; +} + +void CStarField::toggle4() { + _val4 = !_val4; +} + +bool CStarField::set4(bool val) { + bool oldVal = _val4; + _val4 = val; + return oldVal; +} + +int CStarField::get88() const { + return _sub8._field8; +} + +int CStarField::get5() const { + return _val5; +} + +void CStarField::update6() { + _val6 = _sub8._field8 == 2; +} + +int CStarField::get6() const { + return _val6; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h new file mode 100644 index 0000000000..ef1ee29737 --- /dev/null +++ b/engines/titanic/star_control/star_field.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_FIELD_H +#define TITANIC_STAR_FIELD_H + +#include "titanic/star_control/star_control_sub2.h" +#include "titanic/star_control/star_control_sub5.h" +#include "titanic/star_control/star_control_sub7.h" +#include "titanic/star_control/star_control_sub8.h" +#include "titanic/star_control/star_points1.h" +#include "titanic/star_control/star_points2.h" + +namespace Titanic { + +class CStarField : public CStarControlSub2 { +private: + CStarControlSub7 _sub7; + CStarControlSub8 _sub8; + CStarPoints1 _points1; + CStarPoints2 _points2; + CStarControlSub5 _sub5; + int _val1; + int _val2; + int _val3; + bool _val4; + int _val5; + bool _val6; +public: + CStarField(); + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file, int indent); + + bool initDocument(); + + /** + * Renders the contents of the starfield + */ + void render(CVideoSurface *surface, CStarControlSub12 *sub12); + + int get1() const; + void set1(int val); + int get2() const; + void set2(int val); + int get54() const; + void set54(int val); + int get3() const; + void set3(int val); + void toggle4(); + bool set4(bool val); + int get88() const; + int get5() const; + void update6(); + int get6() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_FIELD_H */ diff --git a/engines/titanic/star_control/star_points1.cpp b/engines/titanic/star_control/star_points1.cpp new file mode 100644 index 0000000000..6e698d61f7 --- /dev/null +++ b/engines/titanic/star_control/star_points1.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_points1.h" +#include "titanic/star_control/star_control_sub12.h" +#include "titanic/titanic.h" + +namespace Titanic { + +#define ARRAY_COUNT 876 +const double FACTOR = 3.1415927 * 0.0055555557; + +CStarPoints1::CStarPoints1() { +} + +bool CStarPoints1::initialize() { + // Get a reference to the starfield points resource + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource("STARFIELD/POINTS"); + assert(stream && stream->size() == (12 * ARRAY_COUNT)); + + _data.resize(ARRAY_COUNT); + for (int idx = 0; idx < ARRAY_COUNT; ++idx) { + FVector &entry = _data[idx]; + + // Get the next set of values + double v1 = stream->readUint32LE(); + double v2 = stream->readUint32LE(); + stream->readUint32LE(); + + v1 *= 0.0099999998 * FACTOR; + v2 *= 0.015 * FACTOR; + + entry._x = cos(v2) * 3000000.0 * cos(v1); + entry._y = sin(v2) * 3000000.0 * cos(v1); + entry._z = sin(v1) * 3000000.0; + } + + return true; +} + +void CStarPoints1::draw(CSurfaceArea *surface, CStarControlSub12 *img) { + if (_data.empty()) + return; + + + + // TODO +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_points1.h b/engines/titanic/star_control/star_points1.h new file mode 100644 index 0000000000..a6e4ee2ec9 --- /dev/null +++ b/engines/titanic/star_control/star_points1.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_POINTS1_H +#define TITANIC_STAR_POINTS1_H + +#include "common/array.h" +#include "titanic/star_control/surface_area.h" +#include "titanic/star_control/fvector.h" + +namespace Titanic { + +class CStarControlSub12; + +class CStarPoints1 { +private: + Common::Array<FVector> _data; +public: + CStarPoints1(); + + /** + * Initialize the array + */ + bool initialize(); + + /** + * Draw the starfield points + */ + void draw(CSurfaceArea *surface, CStarControlSub12 *img); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_POINTS1_H */ diff --git a/engines/titanic/star_control/star_points2.cpp b/engines/titanic/star_control/star_points2.cpp new file mode 100644 index 0000000000..4fea298f93 --- /dev/null +++ b/engines/titanic/star_control/star_points2.cpp @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_points2.h" +#include "titanic/titanic.h" + +namespace Titanic { + +#define ARRAY_COUNT 80 +const double FACTOR = 3.1415927 * 0.0055555557; + +bool CStarPoints2::initialize() { + // Get a reference to the starfield points resource + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource("STARFIELD/POINTS2"); + + _data.resize(ARRAY_COUNT); + for (int rootCtr = 0; rootCtr < ARRAY_COUNT; ++rootCtr) { + // Get the number of sub-entries for this entry + int count = stream->readUint32LE(); + double v1, v2; + + // Read in the sub-entries + RootEntry &rootEntry = _data[rootCtr]; + rootEntry.resize(count * 2); + for (int idx = 0; idx < count * 2; ++idx) { + DataEntry &entry = rootEntry[idx]; + v1 = stream->readSint32LE(); + v2 = stream->readSint32LE(); + v1 *= 0.015 * FACTOR; + v2 *= 0.0099999998 * FACTOR; + entry._v1 = cos(v1) * 3000000.0 * cos(v2); + entry._v2 = sin(v1) * 3000000.0 * cos(v2); + entry._v3 = sin(v2) * 3000000.0; + } + } + + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_points2.h b/engines/titanic/star_control/star_points2.h new file mode 100644 index 0000000000..31bded4069 --- /dev/null +++ b/engines/titanic/star_control/star_points2.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_POINTS2_H +#define TITANIC_STAR_POINTS2_H + +#include "common/array.h" + +namespace Titanic { + +class CStarPoints2 { + struct DataEntry { + int _v1; + int _v2; + int _v3; + }; + + class RootEntry : public Common::Array<DataEntry> { + public: + int _field0; + RootEntry() : _field0(0) {} + }; +private: + Common::Array<RootEntry> _data; +public: + /** + * Initializes the data + */ + bool initialize(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_POINTS2_H */ diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp new file mode 100644 index 0000000000..f5d1d36c49 --- /dev/null +++ b/engines/titanic/star_control/star_view.cpp @@ -0,0 +1,135 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/screen_manager.h" +#include "titanic/star_control/star_view.h" +#include "titanic/star_control/star_control.h" +#include "titanic/star_control/star_field.h" +#include "titanic/core/game_object.h" + +namespace Titanic { + +CStarView::CStarView() : _sub12(nullptr, nullptr), _sub13((void *)nullptr), + _owner(nullptr), _starField(nullptr), _videoSurface(nullptr), _field118(0), + _videoSurface2(nullptr), _field210(0), _homePhotoMask(nullptr), + _field218(0), _field21C(0) { + CStar20Data data = { 0, 0, 0x47C35000, 0, 0x41A00000, + 0x3F800000, 0x3F800000, 0x3F800000 }; + + _sub12.proc3(&data); +} + +void CStarView::load(SimpleFile *file, int param) { + if (!param) { + _sub12.load(file, param); + + _field118 = file->readNumber(); + if (_field118) + _sub13.load(file, 0); + + _field218 = file->readNumber(); + _field21C = file->readNumber(); + } +} + +void CStarView::save(SimpleFile *file, int indent) { + _sub12.save(file, indent); + + file->writeNumberLine(_field118, indent); + if (_field118) + _sub13.save(file, indent); + + file->writeNumberLine(_field218, indent); + file->writeNumberLine(_field21C, indent); +} + +void CStarView::setup(CScreenManager *screenManager, CStarField *starField, CStarControl *starControl) { + _starField = starField; + _owner = starControl; +} + +void CStarView::reset() { + // TODO +} + +void CStarView::draw(CScreenManager *screenManager) { + if (!screenManager || !_videoSurface || !_starField) + return; + + if (_fader.isActive()) { + CVideoSurface *surface = _field21C ? _videoSurface2 : _videoSurface; + surface = _fader.fade(screenManager, surface); + screenManager->blitFrom(SURFACE_PRIMARY, surface); + } else { + Point destPos(20, 10); + + if (_field21C) { + screenManager->blitFrom(SURFACE_PRIMARY, _videoSurface2, &destPos); + + if (!_homePhotoMask && _owner) { + _homePhotoMask = _owner->getHiddenObject("HomePhotoMask"); + } + + if (_homePhotoMask) + _homePhotoMask->draw(screenManager, Point(20, 187)); + } else { + fn1(); + + // Render the display + _videoSurface->clear(); + _videoSurface->lock(); + _starField->render(_videoSurface, &_sub12); + _videoSurface->unlock(); + + // Blit the resulting surface to the screen + screenManager->blitFrom(SURFACE_PRIMARY, _videoSurface, &destPos); + } + } +} + +void CStarView::MouseButtonDownMsg(int unused, const Point &pt) { + // TODO +} + +void CStarView::MouseMoveMsg(int unused, const Point &pt) { + // TODO +} + +CErrorCode CStarView::KeyCharMsg(int key) { + // TODO + return CErrorCode(); +} + +bool CStarView::canSetStarDestination() const { + // TODO + return false; +} + +void CStarView::starDestinationSet() { + // TODO +} + +void CStarView::fn1() { + // TODO +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h new file mode 100644 index 0000000000..bcba5ac436 --- /dev/null +++ b/engines/titanic/star_control/star_view.h @@ -0,0 +1,107 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_VIEW_H +#define TITANIC_STAR_VIEW_H + +#include "titanic/support/simple_file.h" +#include "titanic/support/video_surface.h" +#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_control_sub13.h" +#include "titanic/star_control/surface_fader.h" +#include "titanic/star_control/error_code.h" + +namespace Titanic { + +class CStarControl; +class CStarField; + +class CStarView { +private: + CStarControl *_owner; + CStarField *_starField; + CVideoSurface *_videoSurface; + CStarControlSub12 _sub12; + int _field118; + CStarControlSub13 _sub13; + CSurfaceFader _fader; + CVideoSurface *_videoSurface2; + int _field210; + CGameObject *_homePhotoMask; + int _field218; + int _field21C; +private: + void fn1(); +public: + CStarView(); + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file, int param); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file, int indent); + + /** + * Sets references used by the view + */ + void setup(CScreenManager *screenManager, CStarField *starField, CStarControl *starControl); + + void reset(); + + /** + * Allows the item to draw itself + */ + void draw(CScreenManager *screenManager); + + /** + * Handles mouse down messages + */ + void MouseButtonDownMsg(int unused, const Point &pt); + + /** + * Handles mouse move messages + */ + void MouseMoveMsg(int unused, const Point &pt); + + /** + * Handles keyboard messages + */ + CErrorCode KeyCharMsg(int key); + + /** + * Returns true if a star destination can be set + */ + bool canSetStarDestination() const; + + /** + * Called when a star destination is set + */ + void starDestinationSet(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_RENDERER_H */ diff --git a/engines/titanic/star_control/surface_area.cpp b/engines/titanic/star_control/surface_area.cpp new file mode 100644 index 0000000000..77f8222dad --- /dev/null +++ b/engines/titanic/star_control/surface_area.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/surface_area.h" + +namespace Titanic { + +CSurfaceArea::CSurfaceArea(CVideoSurface *surface) { + _width = surface->getWidth(); + _height = surface->getHeight(); + _pitch = surface->getPitch(); + + // Original supported other pixel depths + _bpp = surface->getPixelDepth(); + assert(_bpp == 2); + _pixelsPtr = surface->getPixels(); + + initialize(); +} + +void CSurfaceArea::initialize() { + _bounds = Rect(0, 0, _width - 1, _height - 1); + _centroid = Point(_width / 2, _height / 2); + _field22 = _field21 = _field20 = 0xFF; + _field27 = _field26 = _field25 = 0; + _field24 = _field23 = 0; + _field28 = _field2C = 0; + _field38 = 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/surface_area.h b/engines/titanic/star_control/surface_area.h new file mode 100644 index 0000000000..4d1913123c --- /dev/null +++ b/engines/titanic/star_control/surface_area.h @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SURFACE_OBJ_H +#define TITANIC_SURFACE_OBJ_H + +#include "titanic/support/rect.h" +#include "titanic/support/video_surface.h" + +namespace Titanic { + +class CSurfaceArea { +private: + /** + * Initialize data for the class + */ + void initialize(); +public: + int _field0; + int _width; + int _height; + int _pitch; + int _bpp; + uint16 *_pixelsPtr; + Point _centroid; + byte _field20; + byte _field21; + byte _field22; + byte _field23; + byte _field24; + byte _field25; + byte _field26; + byte _field27; + int _field28; + int _field2C; + int _field30; + int _field34; + int _field38; + Rect _bounds; +public: + CSurfaceArea(CVideoSurface *surface); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CONTROL_SUB16_H */ diff --git a/engines/titanic/star_control/surface_fader.cpp b/engines/titanic/star_control/surface_fader.cpp new file mode 100644 index 0000000000..089ad51717 --- /dev/null +++ b/engines/titanic/star_control/surface_fader.cpp @@ -0,0 +1,73 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/surface_fader.h" +#include "common/system.h" +#include "graphics/pixelformat.h" + +namespace Titanic { + +CSurfaceFader::CSurfaceFader() : CSurfaceFaderBase() { + _dataP = new byte[_count]; + + for (int idx = 0; idx < _count; ++idx) { + // TODO: Setup data bytes + } +} + +CSurfaceFader::~CSurfaceFader() { + delete[] _dataP; +} + +void CSurfaceFader::copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurface) { + const uint16 *srcPixelP = srcSurface._pixelsPtr; + uint16 *destPixelP = destSurface._pixelsPtr; + + // Currently we only support 2 bytes per pixel surfaces + assert(srcSurface._bpp == 2); + + byte dataVal = _dataP[_index]; + double fraction = (double)dataVal / ((double)(_count - 1)); + if (!_fadeIn) + // For fade outs, reverse the percentage visibility + fraction = 1.0 - fraction; + + // Iterate through the pixels + byte r, g, b; + Graphics::PixelFormat format = g_system->getScreenFormat(); + + for (int yp = 0; yp < srcSurface._height; ++yp) { + for (int xp = 0; xp < srcSurface._width; ++xp, ++srcPixelP, ++destPixelP) { + format.colorToRGB(*srcPixelP, r, g, b); + r = (byte)((double)r * fraction); + g = (byte)((double)g * fraction); + b = (byte)((double)b * fraction); + *destPixelP = format.RGBToColor(r, g, b); + } + } +} + +void CSurfaceFader::setFadeIn(bool fadeIn) { + _fadeIn = fadeIn; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/surface_fader.h b/engines/titanic/star_control/surface_fader.h new file mode 100644 index 0000000000..650cbbb19b --- /dev/null +++ b/engines/titanic/star_control/surface_fader.h @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SURFACE_FADER_H +#define TITANIC_SURFACE_FADER_H + +#include "titanic/star_control/surface_fader_base.h" + +namespace Titanic { + +class CSurfaceFader: public CSurfaceFaderBase { +private: + byte *_dataP; + bool _fadeIn; +protected: + /** + * Create a faded version of the source surface at the given dest + */ + virtual void copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurface); +public: + CSurfaceFader(); + virtual ~CSurfaceFader(); + + /** + * Sets whether a fade in (versus a fade out) should be done + */ + void setFadeIn(bool fadeIn); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SURFACE_SHADER_H */ diff --git a/engines/titanic/star_control/surface_fader_base.cpp b/engines/titanic/star_control/surface_fader_base.cpp new file mode 100644 index 0000000000..dfd7c4ab1d --- /dev/null +++ b/engines/titanic/star_control/surface_fader_base.cpp @@ -0,0 +1,78 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/surface_fader_base.h" + +namespace Titanic { + +CSurfaceFaderBase::CSurfaceFaderBase() : _index(-1), _count(32), + _videoSurface(nullptr) { +} + +CSurfaceFaderBase::~CSurfaceFaderBase() { + delete _videoSurface; +} + +void CSurfaceFaderBase::reset() { + _index = 0; +} + +bool CSurfaceFaderBase::setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface) { + int width = srcSurface->getWidth(); + int height = srcSurface->getHeight(); + + if (_videoSurface) { + if (width == _videoSurface->getWidth() && _videoSurface->getHeight()) + // Allocated surface already matches new size + return true; + + // Different sizes, so delete old surface + delete _videoSurface; + } + + _videoSurface = screenManager->createSurface(width, height); + return true; +} + +CVideoSurface *CSurfaceFaderBase::fade(CScreenManager *screenManager, CVideoSurface *srcSurface) { + if (_index == -1 || _index >= _count) + return srcSurface; + + if (!_count && !setupSurface(screenManager, srcSurface)) + return nullptr; + + srcSurface->lock(); + _videoSurface->lock(); + CSurfaceArea srCSurfaceArea(srcSurface); + CSurfaceArea destSurfaceObj(_videoSurface); + + // Copy the surface with fading + copySurface(srCSurfaceArea, destSurfaceObj); + + srcSurface->unlock(); + _videoSurface->unlock(); + + ++_index; + return _videoSurface; +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/surface_fader_base.h b/engines/titanic/star_control/surface_fader_base.h new file mode 100644 index 0000000000..463183537b --- /dev/null +++ b/engines/titanic/star_control/surface_fader_base.h @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SURFACE_FADER_BASE_H +#define TITANIC_SURFACE_FADER_BASE_H + +#include "titanic/support/video_surface.h" +#include "titanic/support/screen_manager.h" +#include "titanic/star_control/surface_area.h" + +namespace Titanic { + +class CSurfaceFaderBase { +private: + /** + * Sets up an internal surface to match the size of the specified one + */ + bool setupSurface(CScreenManager *screenManager, CVideoSurface *srcSurface); +protected: + /** + * Create a faded version of the source surface at the given dest + */ + virtual void copySurface(CSurfaceArea &srcSurface, CSurfaceArea &destSurface) = 0; +public: + int _index; + int _count; + CVideoSurface *_videoSurface; +public: + CSurfaceFaderBase(); + virtual ~CSurfaceFaderBase(); + + /** + * Reset fading back to the start + */ + virtual void reset(); + + /** + * Creates a faded version of the passed source surface, based on a percentage + * visibility specified by _index of _count + */ + virtual CVideoSurface *fade(CScreenManager *screenManager, CVideoSurface *srcSurface); + + /** + * Returns true if a fade is in progress + */ + bool isActive() const { return _index != -1 && _index < _count; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SURFACE_FADER_BASE_H */ diff --git a/engines/titanic/support/avi_surface.cpp b/engines/titanic/support/avi_surface.cpp new file mode 100644 index 0000000000..c37bd83616 --- /dev/null +++ b/engines/titanic/support/avi_surface.cpp @@ -0,0 +1,361 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/avi_surface.h" +#include "titanic/support/screen_manager.h" +#include "titanic/support/video_surface.h" +#include "common/system.h" +#include "graphics/pixelformat.h" +#include "video/avi_decoder.h" + +namespace Titanic { + +Video::AVIDecoder::AVIVideoTrack &AVIDecoder::getVideoTrack() { + for (TrackListIterator it = getTrackListBegin(); it != getTrackListEnd(); it++) + if ((*it)->getTrackType() == Track::kTrackTypeVideo) + return *static_cast<AVIVideoTrack *>(*it); + + error("Could not find video track"); +} + +/** + * Track filter for AVIDecoder that filters out any secondary video track + */ +static bool primaryTrackSelect(bool isVideo, int trackCounter) { + return !isVideo || trackCounter == 0; +} + +/** + * Track filter for AVIDecoder that only accepts the secondary video track + * for a video, if present + */ +static bool secondaryTrackSelect(bool isVideo, int trackCounter) { + return isVideo && trackCounter > 0; +} + +AVISurface::AVISurface(const CResourceKey &key) { + _videoSurface = nullptr; + _streamCount = 0; + _movieFrameSurface[0] = _movieFrameSurface[1] = nullptr; + + // Reset current frame. We need to keep track of frames separately from the decoders, + // since it needs to be able to go beyond the frame count or to negative to allow + // correct detection of when range playbacks have finished + _currentFrame = -1; + _isReversed = false; + + // Create a decoder for the audio (if any) and primary video track + _decoders[0] = new AVIDecoder(Audio::Mixer::kPlainSoundType, primaryTrackSelect); + if (!_decoders[0]->loadFile(key.getString())) + error("Could not open video - %s", key.getString().c_str()); + + _streamCount = 1; + + // Create a decoder for any secondary video track + AVIDecoder *decoder2 = new AVIDecoder(Audio::Mixer::kPlainSoundType, secondaryTrackSelect); + if (decoder2->loadFile(key.getString())) { + _decoders[1] = decoder2; + ++_streamCount; + } else { + delete decoder2; + _decoders[1] = nullptr; + } +} + +AVISurface::~AVISurface() { + if (_videoSurface) + _videoSurface->_transBlitFlag = false; + delete _movieFrameSurface[0]; + delete _movieFrameSurface[1]; + delete _decoders[0]; + delete _decoders[1]; +} + +bool AVISurface::play(uint flags, CGameObject *obj) { + if (flags & MOVIE_REVERSE) + return play(_decoders[0]->getFrameCount() - 1, 0, flags, obj); + else + return play(0, _decoders[0]->getFrameCount() - 1, flags, obj); +} + +bool AVISurface::play(int startFrame, int endFrame, uint flags, CGameObject *obj) { + if (flags & MOVIE_STOP_PREVIOUS) + stop(); + + return play(startFrame, endFrame, -1, flags, obj); +} + +bool AVISurface::play(int startFrame, int endFrame, int initialFrame, uint flags, CGameObject *obj) { + CMovieRangeInfo *info = new CMovieRangeInfo(); + info->_startFrame = startFrame; + info->_endFrame = endFrame; + info->_isReversed = endFrame < startFrame; + info->_initialFrame = 0; + info->_isRepeat = flags & MOVIE_REPEAT; + + if (obj) { + CMovieEvent *me = new CMovieEvent(); + me->_type = MET_MOVIE_END; + me->_startFrame = startFrame; + me->_endFrame = endFrame; + me->_initialFrame = 0; + me->_gameObject = obj; + + info->addEvent(me); + } + + _movieRangeInfo.push_back(info); + + if (_movieRangeInfo.size() == 1) { + // First play call, so start the movie playing + setReversed(info->_isReversed); + return startAtFrame(initialFrame); + } else { + return true; + } +} + +void AVISurface::stop() { + _decoders[0]->stop(); + if (_decoders[1]) + _decoders[1]->stop(); + + _movieRangeInfo.destroyContents(); +} + +bool AVISurface::startAtFrame(int frameNumber) { + if (isPlaying()) + // If it's already playing, then don't allow it + return false; + + if (frameNumber == -1) + // Default to starting frame of first movie range + frameNumber = _movieRangeInfo.front()->_startFrame; + + // Get the initial frame + seekToFrame(frameNumber); + renderFrame(); + + // Start the playback + _decoders[0]->start(); + if (_decoders[1]) + _decoders[1]->start(); + + return true; +} + +void AVISurface::seekToFrame(uint frameNumber) { + if ((int)frameNumber != getFrame()) { + _decoders[0]->seekToFrame(frameNumber); + if (_decoders[1]) + _decoders[1]->seekToFrame(frameNumber); + + _currentFrame = (int)frameNumber; + } + + renderFrame(); +} + +void AVISurface::setReversed(bool isReversed) { + _decoders[0]->setReverse(isReversed); + if (_decoders[1]) + _decoders[1]->setReverse(isReversed); + + _isReversed = isReversed; +} + +bool AVISurface::handleEvents(CMovieEventList &events) { + if (!isPlaying()) + return true; + + CMovieRangeInfo *info = _movieRangeInfo.front(); + _currentFrame += _isReversed ? -1 : 1; + + int newFrame = _currentFrame; + if ((info->_isReversed && newFrame <= info->_endFrame) || + (!info->_isReversed && newFrame >= info->_endFrame)) { + if (info->_isRepeat) { + newFrame = info->_startFrame; + } else { + info->getMovieEnd(events); + _movieRangeInfo.remove(info); + delete info; + + if (_movieRangeInfo.empty()) { + // NO more ranges, so stop playback + stop(); + } else { + // Not empty, so move onto new first one + info = _movieRangeInfo.front(); + newFrame = info->_startFrame; + } + } + } + + if (isPlaying()) { + if (newFrame != getFrame()) { + // The frame has been changed, so move to new position + setReversed(info->_isReversed); + seekToFrame(newFrame); + } + + // Get any events for the given position + info->getMovieFrame(events, newFrame); + return renderFrame(); + } else { + return false; + } +} + +void AVISurface::setVideoSurface(CVideoSurface *surface) { + _videoSurface = surface; + + // Handling for secondary video stream + if (_decoders[1]) { + const Common::String &streamName = _decoders[1]->getVideoTrack().getName(); + + if (streamName == "mask0") { + _videoSurface->_transparencyMode = TRANS_MASK0; + } else if (streamName == "mask255") { + _videoSurface->_transparencyMode = TRANS_MASK255; + } else if (streamName == "alpha0") { + _videoSurface->_transparencyMode = TRANS_ALPHA0; + } else if (streamName == "alpha255") { + _videoSurface->_transparencyMode = TRANS_ALPHA255; + } + } + + setupDecompressor(); +} + +void AVISurface::setupDecompressor() { + for (int idx = 0; idx < 2; ++idx) { + if (!_decoders[idx]) + continue; + AVIDecoder &decoder = *_decoders[idx]; + + // Setup frame surface + _movieFrameSurface[idx] = new Graphics::ManagedSurface(decoder.getWidth(), decoder.getHeight(), + g_system->getScreenFormat()); + + // TODO: See whether this simplified form of original works + if (idx == 1) + _videoSurface->_transBlitFlag = true; + } +} + +uint AVISurface::getWidth() const { + return _decoders[0]->getWidth(); +} + +uint AVISurface::getHeight() const { + return _decoders[0]->getHeight(); +} + +void AVISurface::setFrame(int frameNumber) { + // If playback was in process, stop it + if (isPlaying()) + stop(); + + // Ensure the frame number is valid + if (frameNumber >= (int)_decoders[0]->getFrameCount()) + frameNumber = _decoders[0]->getFrameCount() - 1; + + seekToFrame(frameNumber); + renderFrame(); +} + +bool AVISurface::isNextFrame() const { + return _decoders[0]->getTimeToNextFrame() == 0; +} + +bool AVISurface::renderFrame() { + // Check there's a frame ready for display + if (!_decoders[0]->needsUpdate()) + return false; + + // Decode each decoder's video stream into the appropriate surface + for (int idx = 0; idx < _streamCount; ++idx) { + const Graphics::Surface *frame = _decoders[idx]->decodeNextFrame(); + + if (_movieFrameSurface[idx]->format == frame->format) { + _movieFrameSurface[idx]->blitFrom(*frame); + } else { + // Format mis-match, so we need to convert the frame + Graphics::Surface *s = frame->convertTo(_movieFrameSurface[idx]->format, + _decoders[idx]->getPalette()); + _movieFrameSurface[idx]->blitFrom(*s); + s->free(); + delete s; + } + } + + // Blit the primary video frame onto the main overall surface + _videoSurface->lock(); + _videoSurface->getRawSurface()->blitFrom(*_movieFrameSurface[0]); + _videoSurface->unlock(); + + return false; +} + +bool AVISurface::addEvent(int frameNumber, CGameObject *obj) { + if (!_movieRangeInfo.empty()) { + CMovieRangeInfo *tail = _movieRangeInfo.back(); + if (frameNumber == -1) + frameNumber = tail->_startFrame; + + CMovieEvent *me = new CMovieEvent(); + me->_type = MET_FRAME; + me->_startFrame = 0; + me->_endFrame = 0; + me->_initialFrame = frameNumber; + me->_gameObject = obj; + tail->addEvent(me); + + return _movieRangeInfo.size() == 1 && frameNumber == getFrame(); + } + + return false; +} + +void AVISurface::setFrameRate(double rate) { + _decoders[0]->setRate(Common::Rational(rate)); + if (_decoders[1]) + _decoders[1]->setRate(Common::Rational(rate)); +} + +Graphics::ManagedSurface *AVISurface::getSecondarySurface() { + return _streamCount <= 1 ? nullptr : _movieFrameSurface[1]; +} + +Graphics::ManagedSurface *AVISurface::duplicateSecondaryFrame() const { + if (_streamCount <= 1) { + return nullptr; + } else { + Graphics::ManagedSurface *dest = new Graphics::ManagedSurface(_movieFrameSurface[1]->w, + _movieFrameSurface[1]->h, _movieFrameSurface[1]->format); + dest->blitFrom(*_movieFrameSurface[1]); + return dest; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/avi_surface.h b/engines/titanic/support/avi_surface.h new file mode 100644 index 0000000000..d21182bca9 --- /dev/null +++ b/engines/titanic/support/avi_surface.h @@ -0,0 +1,183 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_AVI_SURFACE_H +#define TITANIC_AVI_SURFACE_H + +#include "video/avi_decoder.h" +#include "graphics/managed_surface.h" +#include "titanic/core/resource_key.h" +#include "titanic/support/movie_range_info.h" + +namespace Titanic { + +class CSoundManager; +class CVideoSurface; + +enum MovieFlag { + MOVIE_REPEAT = 1, MOVIE_STOP_PREVIOUS = 2, MOVIE_NOTIFY_OBJECT = 4, + MOVIE_REVERSE = 8, MOVIE_GAMESTATE = 0x10 +}; + +class AVIDecoder : public Video::AVIDecoder { +public: + AVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType, SelectTrackFn trackFn = nullptr) : + Video::AVIDecoder(soundType, trackFn) {} + AVIDecoder(const Common::Rational &frameRateOverride, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType, + SelectTrackFn trackFn = nullptr) : Video::AVIDecoder(frameRateOverride, soundType, trackFn) {} + + Video::AVIDecoder::AVIVideoTrack &getVideoTrack(); +}; + +class AVISurface { +private: + AVIDecoder *_decoders[2]; + CVideoSurface *_videoSurface; + CMovieRangeInfoList _movieRangeInfo; + int _streamCount; + Graphics::ManagedSurface *_movieFrameSurface[2]; + bool _isReversed; + int _currentFrame; +private: + /** + * Render a frame to the video surface + */ + bool renderFrame(); + + /** + * Sets up for video decompression + */ + void setupDecompressor(); +protected: + /** + * Start playback at the specified frame + */ + bool startAtFrame(int frameNumber); + + /** + * Sets whether the movie is playing in reverse + */ + void setReversed(bool isReversed); + + /** + * Seeks to a given frame number in the video + */ + virtual void seekToFrame(uint frameNumber); +public: + CSoundManager *_soundManager; + bool _hasAudio; + double _frameRate; +public: + AVISurface(const CResourceKey &key); + virtual ~AVISurface(); + + /** + * Start playing the loaded AVI video + */ + virtual bool play(uint flags, CGameObject *obj); + + /** + * Start playing the loaded AVI video + */ + virtual bool play(int startFrame, int endFrame, uint flags, CGameObject *obj); + + /** + * Start playing the loaded AVI video + */ + virtual bool play(int startFrame, int endFrame, int initialFrame, uint flags, CGameObject *obj); + + /** + * Stop the currently playing video + */ + virtual void stop(); + + /** + * Return true if a video is currently playing + */ + virtual bool isPlaying() const { return _decoders[0]->isPlaying(); } + + /** + * Handle any movie events relevent for the frame + */ + virtual bool handleEvents(CMovieEventList &events); + + /** + * Set the video surface the AVI Surface will render on + */ + void setVideoSurface(CVideoSurface *surface); + + /** + * Get the width of the video + */ + uint getWidth() const; + + /** + * Get the height of the video + */ + uint getHeight() const; + + /** + * Set the current frame + */ + void setFrame(int frameNumber); + + /** + * Gets the current frame + */ + int getFrame() const { return _currentFrame; } + + /** + * Add a movie event + */ + bool addEvent(int frameNumber, CGameObject *obj); + + /** + * Set the frame rate + */ + void setFrameRate(double rate); + + /** + * Returns the surface for the secondary video track frame, if present + */ + Graphics::ManagedSurface *getSecondarySurface(); + + /** + * Get a reference to the movie range info list + */ + const CMovieRangeInfoList *getMovieRangeInfo() const { + return &_movieRangeInfo; + } + + /** + * Duplicates the secondary frame, if the movie has a second video track + */ + Graphics::ManagedSurface *duplicateSecondaryFrame() const; + + /** + * Returns true if it's time for the next + */ + bool isNextFrame() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_AVI_SURFACE_H */ diff --git a/engines/titanic/support/credit_text.cpp b/engines/titanic/support/credit_text.cpp new file mode 100644 index 0000000000..0e9715aaa6 --- /dev/null +++ b/engines/titanic/support/credit_text.cpp @@ -0,0 +1,153 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/credit_text.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CCreditText::CCreditText() : _screenManagerP(nullptr), _field14(0), + _ticks(0), _fontHeight(1), _objectP(nullptr), _totalHeight(0), + _field40(0), _field44(0), _field48(0), _field4C(0), _field50(0), + _field54(0), _field58(0), _field5C(0) { +} + +void CCreditText::clear() { + _groups.destroyContents(); + _objectP = nullptr; +} + +void CCreditText::load(CGameObject *obj, CScreenManager *screenManager, + const Rect &rect, int v) { + _objectP = obj; + _screenManagerP = screenManager; + _field14 = v; + + setup(); + + _ticks = g_vm->_events->getTicksCount(); + _field40 = 0; + _field44 = 0xFF; + _field48 = 0xFF; + _field4C = 0xFF; + _field50 = 0; + _field54 = 0; + _field58 = 0; + _field5C = 0; +} + +void CCreditText::setup() { + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource( + CString::format("TEXT/155")); + int oldFontNumber = _screenManagerP->setFontNumber(3); + _fontHeight = _screenManagerP->getFontHeight(); + + while (stream->pos() < stream->size()) { + // Read in the line + CString srcLine = readLine(stream); + + // Create a new group and line within it + CCreditLineGroup *group = new CCreditLineGroup(); + CCreditLine *line = new CCreditLine(srcLine, + _screenManagerP->stringWidth(srcLine)); + group->_lines.push_back(line); + + // Loop to add more lines to the group + bool hasDots = false; + while (stream->pos() < stream->size()) { + srcLine = readLine(stream); + if (srcLine.empty()) + break; + + line = new CCreditLine(srcLine, + _screenManagerP->stringWidth(srcLine)); + group->_lines.push_back(line); + + if (srcLine.contains("....")) + hasDots = true; + } + + _groups.push_back(group); + } + + _groupIt = _groups.begin(); + _lineIt = (*_groupIt)->_lines.begin(); + _totalHeight = _objectP->getBounds().height() + _fontHeight * 2; +} + +CString CCreditText::readLine(Common::SeekableReadStream *stream) { + CString line; + char c = stream->readByte(); + + while (c != '\r' && c != '\n' && c != '\0') { + line += c; + + if (stream->pos() == stream->size()) + break; + c = stream->readByte(); + } + + if (c == '\r') { + // Read following '\n' + stream->readByte(); + } + + return line; +} + +void CCreditText::handleDots(CCreditLineGroup *group) { + uint maxWidth = 0; + CCreditLines::iterator second = group->_lines.begin(); + ++second; + + // Figure out the maximum width of secondary lines + for (CCreditLines::iterator i = second; i != group->_lines.end(); ++i) + maxWidth = MAX(maxWidth, (*i)->_lineWidth); + + int charWidth = _screenManagerP->stringWidth("."); + + // Process the secondary lines + for (CCreditLines::iterator i = second; i != group->_lines.end(); ++i) { + CCreditLine *line = *i; + if (line->_lineWidth >= maxWidth) + continue; + + int dotsCount = (maxWidth + charWidth / 2 - line->_lineWidth) / charWidth; + int dotIndex = line->_line.indexOf("...."); + + if (dotIndex > 0) { + CString leftStr = line->_line.left(dotIndex); + CString dotsStr('.', dotsCount); + CString rightStr = line->_line.right(dotIndex); + + line->_line = CString::format("%s%s%s", leftStr.c_str(), + dotsStr.c_str(), rightStr.c_str()); + line->_lineWidth = maxWidth; + } + } +} + +bool CCreditText::draw() { + return false; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/credit_text.h b/engines/titanic/support/credit_text.h new file mode 100644 index 0000000000..ec8fc22cda --- /dev/null +++ b/engines/titanic/support/credit_text.h @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_CREDIT_TEXT_H +#define TITANIC_CREDIT_TEXT_H + +#include "titanic/core/list.h" + +namespace Titanic { + +class CGameObject; +class CScreenManager; + +class CCreditLine : public ListItem { +public: + CString _line; + uint _lineWidth; +public: + CCreditLine() : _lineWidth(0) {} + CCreditLine(const CString &line, uint lineWidth) : _line(line), _lineWidth(lineWidth) {} +}; +typedef List<CCreditLine> CCreditLines; + +class CCreditLineGroup : public ListItem { +public: + CCreditLines _lines; +}; +typedef List<CCreditLineGroup> CCreditLineGroups; + +class CCreditText { +private: + /** + * Sets up needed data + */ + void setup(); + + /** + * Read in a text line from the passed stream + */ + CString readLine(Common::SeekableReadStream *stream); + + /** + * Handles a group where the .... sequence was encountered + */ + void handleDots(CCreditLineGroup *group); +public: + CScreenManager *_screenManagerP; + Rect _rect; + int _field14; + CCreditLineGroups _groups; + uint _ticks; + uint _fontHeight; + CGameObject *_objectP; + CCreditLineGroups::iterator _groupIt; + CCreditLines::iterator _lineIt; + uint _totalHeight; + int _field40; + int _field44; + int _field48; + int _field4C; + int _field50; + int _field54; + int _field58; + int _field5C; +public: + CCreditText(); + + /** + * Clears the object + */ + void clear(); + + /** + * Sets the game object this override is associated with + */ + void load(CGameObject *obj, CScreenManager *screenManager, + const Rect &rect, int v = 0); + + /** + * Draw the item + */ + bool draw(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_CREDIT_TEXT_H */ diff --git a/engines/titanic/support/direct_draw.cpp b/engines/titanic/support/direct_draw.cpp new file mode 100644 index 0000000000..5ddb25bec9 --- /dev/null +++ b/engines/titanic/support/direct_draw.cpp @@ -0,0 +1,109 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/debug.h" +#include "engines/util.h" +#include "graphics/pixelformat.h" +#include "titanic/titanic.h" +#include "titanic/support/direct_draw.h" + +namespace Titanic { + +DirectDraw::DirectDraw(TitanicEngine *vm) : _vm(vm), + _windowed(false), _fieldC(0), _width(0), _height(0), + _bpp(0), _numBackSurfaces(0), _field24(0) { +} + +void DirectDraw::setDisplayMode(int width, int height, int bpp, int refreshRate) { + debugC(ERROR_BASIC, kDebugGraphics, "DirectDraw::SetDisplayMode (%d x %d), %d bpp", + width, height, bpp); + assert(bpp == 16); + + Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); + initGraphics(width, height, true, &pixelFormat); +} + +void DirectDraw::diagnostics() { + debugC(ERROR_BASIC, kDebugGraphics, "Running DirectDraw Diagnostic..."); +} + +DirectDrawSurface *DirectDraw::createSurfaceFromDesc(const DDSurfaceDesc &desc) { + DirectDrawSurface *surface = new DirectDrawSurface(); + surface->create(desc._w, desc._h); + + return surface; +} + +/*------------------------------------------------------------------------*/ + +DirectDrawManager::DirectDrawManager(TitanicEngine *vm, bool windowed) : _directDraw(vm) { + _mainSurface = nullptr; + _backSurfaces[0] = _backSurfaces[1] = nullptr; + _directDraw._windowed = windowed; +} + +void DirectDrawManager::initVideo(int width, int height, int bpp, int numBackSurfaces) { + debugC(ERROR_BASIC, kDebugGraphics, "Initialising video surfaces"); + _directDraw._width = width; + _directDraw._numBackSurfaces = numBackSurfaces; + _directDraw._height = height; + _directDraw._bpp = bpp; + + if (_directDraw._windowed) { + initWindowed(); + } else { + initFullScreen(); + } +} + +void DirectDrawManager::setResolution() { + // TODO +} + +void DirectDrawManager::proc2() { + +} + +void DirectDrawManager::proc3() { + +} + +void DirectDrawManager::initFullScreen() { + debugC(ERROR_BASIC, kDebugGraphics, "Creating surfaces"); + _directDraw.setDisplayMode(_directDraw._width, _directDraw._height, + _directDraw._bpp, 0); + + _mainSurface = new DirectDrawSurface(); + _mainSurface->create(g_vm->_screen); + _backSurfaces[0] = new DirectDrawSurface(); + _backSurfaces[0]->create(_directDraw._width, _directDraw._height); +} + +DirectDrawSurface *DirectDrawManager::createSurface(int w, int h, int surfaceNum) { + if (surfaceNum) + return nullptr; + + assert(_mainSurface); + return _directDraw.createSurfaceFromDesc(DDSurfaceDesc(w, h)); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/direct_draw.h b/engines/titanic/support/direct_draw.h new file mode 100644 index 0000000000..85c344c600 --- /dev/null +++ b/engines/titanic/support/direct_draw.h @@ -0,0 +1,105 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DIRECT_DRAW_H +#define TITANIC_DIRECT_DRAW_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "titanic/support/direct_draw_surface.h" + +namespace Titanic { + +class TitanicEngine; + +class DirectDraw { +private: + TitanicEngine *_vm; +public: + bool _windowed; + int _fieldC; + int _width; + int _height; + int _bpp; + int _numBackSurfaces; + int _field24; +public: + DirectDraw(TitanicEngine *vm); + + /** + * Sets a new display mode + */ + void setDisplayMode(int width, int height, int bpp, int refreshRate); + + /** + * Logs diagnostic information + */ + void diagnostics(); + + /** + * Create a surface from a passed description record + */ + DirectDrawSurface *createSurfaceFromDesc(const DDSurfaceDesc &desc); +}; + +class DirectDrawManager { +public: + DirectDraw _directDraw; + DirectDrawSurface *_mainSurface; + DirectDrawSurface *_backSurfaces[2]; +public: + DirectDrawManager(TitanicEngine *vm, bool windowed); + + /** + * Initializes video surfaces + * @param width Screen width + * @param height Screen height + * @param bpp Bits per pixel + * @param numBackSurfaces Number of back surfaces + */ + void initVideo(int width, int height, int bpp, int numBackSurfaces); + + void setResolution(); + + void proc2(); + + void proc3(); + + /** + * Initializes the surfaces in windowed mode + */ + void initWindowed() { initFullScreen(); } + + /** + * Initializes the surfaces for the screen + */ + void initFullScreen(); + + /** + * Create a surface + */ + DirectDrawSurface *createSurface(int w, int h, int surfaceNum); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DIRECT_DRAW_H */ diff --git a/engines/titanic/support/direct_draw_surface.cpp b/engines/titanic/support/direct_draw_surface.cpp new file mode 100644 index 0000000000..9ebda15b0e --- /dev/null +++ b/engines/titanic/support/direct_draw_surface.cpp @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/direct_draw_surface.h" + +namespace Titanic { + +DirectDrawSurface::DirectDrawSurface() : _surface(nullptr), + _disposeAfterUse(DisposeAfterUse::YES) { +} + +DirectDrawSurface::~DirectDrawSurface() { + free(); +} + +void DirectDrawSurface::create(Graphics::ManagedSurface *surface) { + free(); + _surface = surface; + _disposeAfterUse = DisposeAfterUse::NO; +} + +void DirectDrawSurface::create(int w, int h) { + Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); + _surface = new Graphics::ManagedSurface(w, h, pixelFormat); + _disposeAfterUse = DisposeAfterUse::YES; +} + +void DirectDrawSurface::free() { + if (_disposeAfterUse == DisposeAfterUse::YES) + delete _surface; + _surface = nullptr; + _disposeAfterUse = DisposeAfterUse::NO; +} + +Graphics::ManagedSurface *DirectDrawSurface::lock(const Rect *bounds, int flags) { + assert(!_surface->empty()); + return _surface; +} + +void DirectDrawSurface::unlock() { + assert(_surface->w != 0 && _surface->h != 0); +} + +void DirectDrawSurface::fill(const Rect *bounds, uint32 color) { + Rect tempBounds; + + assert(_surface); + if (bounds) { + // Bounds are provided, clip them to the bounds of this surface + tempBounds = *bounds; + tempBounds.clip(Rect(0, 0, _surface->w, _surface->h)); + } else { + // No bounds provided, so use the entire surface + tempBounds = Rect(0, 0, _surface->w, _surface->h); + } + + // Fill the area + _surface->fillRect(tempBounds, color); +} + +void DirectDrawSurface::fillRect(Rect *rect, byte r, byte g, byte b) { + uint color = _surface->format.RGBToColor(r, g, b); + Rect tempRect = rect ? *rect : Rect(0, 0, getWidth(), getHeight()); + + _surface->fillRect(tempRect, color); +} + +void DirectDrawSurface::blit(const Rect &destRect, DirectDrawSurface *srcSurface, Rect &srcRect) { + assert(srcSurface); + if (!destRect.isEmpty()) + _surface->transBlitFrom(*srcSurface->_surface, srcRect, destRect, (uint)-1); +} + +void DirectDrawSurface::blit(const Point &destPos, DirectDrawSurface *srcSurface, Rect *bounds) { + if (bounds) + _surface->blitFrom(*srcSurface->_surface, *bounds, destPos); + else + _surface->blitFrom(*srcSurface->_surface, destPos); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/direct_draw_surface.h b/engines/titanic/support/direct_draw_surface.h new file mode 100644 index 0000000000..af19e369d2 --- /dev/null +++ b/engines/titanic/support/direct_draw_surface.h @@ -0,0 +1,126 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DIRECT_DRAW_SURFACE_H +#define TITANIC_DIRECT_DRAW_SURFACE_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "graphics/managed_surface.h" +#include "titanic/support/rect.h" + +namespace Titanic { + +class TitanicEngine; + +struct DDSurfaceDesc { + int _w; + int _h; + int _flags; + int _caps; + + DDSurfaceDesc(int w, int h) : _w(w), _h(h), _flags(0x1006), _caps(64) {} +}; + +class DirectDrawSurface { +private: + Graphics::ManagedSurface *_surface; + DisposeAfterUse::Flag _disposeAfterUse; +public: + DirectDrawSurface(); + ~DirectDrawSurface(); + + /** + * Create a surface + */ + void create(int w, int h); + + /** + * Create a surface based on a passed surface + */ + void create(Graphics::ManagedSurface *surface); + + /** + * Frees the surface + */ + void free(); + + /** + * Return the size of the surface in ytes + */ + int getSize() const { return _surface->pitch * _surface->h; } + + /** + * Return the surface width + */ + int getWidth() const { return _surface->w; } + + /** + * Return the surface width + */ + int getHeight() const { return _surface->h; } + + /** + * Return the surface pitch + */ + int getPitch() const { return _surface->pitch; } + + /** + * Return the surface's format + */ + const Graphics::PixelFormat &getFormat() { return _surface->format; } + + /** + * Lock the surface for access + */ + Graphics::ManagedSurface *lock(const Rect *bounds, int flags); + + /** + * Unlocks the surface at the end of direct accesses + */ + void unlock(); + + /** + * Fills an area of the surfae with the specified color. If no bounds are passed, + * then the entire surface is filled + */ + void fill(const Rect *bounds, uint32 color); + + /** + * Fill an area with a specific color + */ + void fillRect(Rect *rect, byte r, byte g, byte b); + + /** + * Copy data from a source surfcae into this one + */ + void blit(const Rect &destRect, DirectDrawSurface *srcSurface, Rect &srcRect); + + /** + * Copy data from a source surfcae into this one + */ + void blit(const Point &destPos, DirectDrawSurface *srcSurface, Rect *bounds); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DIRECT_DRAW_SURFACE_H */ diff --git a/engines/titanic/support/exe_resources.cpp b/engines/titanic/support/exe_resources.cpp new file mode 100644 index 0000000000..522e92f718 --- /dev/null +++ b/engines/titanic/support/exe_resources.cpp @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/exe_resources.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CExeResources::CExeResources() : _owner(nullptr), _field4(0), _field8(0), + _fieldC(0), _field10(0), _field14(0), _field18(0) { +} + +void CExeResources::reset(CScriptHandler *owner, int val1, int val2) { + _owner = owner; + _field18 = val2; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/exe_resources.h b/engines/titanic/support/exe_resources.h new file mode 100644 index 0000000000..993c34db97 --- /dev/null +++ b/engines/titanic/support/exe_resources.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_EXE_RESOURCES_H +#define TITANIC_EXE_RESOURCES_H + +namespace Titanic { + +class CScriptHandler; + +enum FileHandle { HANDLE_STDIN = 0, HANDLE_STDOUT = 1, HANDLE_STDERR = 2 }; + +class CExeResources { +public: + CScriptHandler *_owner; + int _field4; + int _field8; + int _fieldC; + int _field10; + int _field14; + int _field18; +public: + CExeResources(); + + void reset(CScriptHandler *owner, int val1, int val2); + + bool is18Equals(int val) const { return _field18 == val; } + int get18() const { return _field18; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_EXE_RESOURCES_H */ diff --git a/engines/titanic/support/files_manager.cpp b/engines/titanic/support/files_manager.cpp new file mode 100644 index 0000000000..04928b96d6 --- /dev/null +++ b/engines/titanic/support/files_manager.cpp @@ -0,0 +1,132 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/file.h" +#include "titanic/support/files_manager.h" +#include "titanic/game_manager.h" + +namespace Titanic { + +CFilesManager::CFilesManager() : _gameManager(nullptr), _assetsPath("Assets"), + _field0(0), _drive(-1), _field18(0), _field1C(0), _field3C(0) { + loadResourceIndex(); +} + +CFilesManager::~CFilesManager() { + _datFile.close(); +} + +void CFilesManager::loadResourceIndex() { + if (!_datFile.open("titanic.dat")) + error("Could not find titanic.dat data file"); + + uint headerId = _datFile.readUint32BE(); + uint version = _datFile.readUint16LE(); + if (headerId != MKTAG('S', 'V', 'T', 'N') || version < 1) + error("Invalid data file"); + + // Read in entries + uint offset, size; + char c; + Common::String resourceName; + for (;;) { + offset = _datFile.readUint32LE(); + size = _datFile.readUint32LE(); + if (size == 0) + break; + + Common::String resName; + while ((c = _datFile.readByte()) != '\0') + resName += c; + + _resources[resName] = ResourceEntry(offset, size); + } +} + +bool CFilesManager::fileExists(const CString &name) { + Common::File f; + return f.exists(name); +} + +bool CFilesManager::scanForFile(const CString &name) { + if (name.empty()) + return false; + + CString filename = name; + filename.toLowercase(); + + if (filename[0] == 'y' || filename[0] == 'z') + return true; + else if (filename[0] < 'a' || filename[0] > 'c') + return false; + + CString fname = filename; + int idx = fname.indexOf('#'); + if (idx >= 0) { + fname = fname.left(idx); + fname += ".st"; + } + + // Return true if the file exists + if (fileExists(fname)) + return true; + + // Couldn't find file. Start by calling the game manager's viewChange + // method, which handles all active scene objects freeing their resources + if (_gameManager) + _gameManager->viewChange(); + + return false; +} + +void CFilesManager::loadDrive() { + assert(_drive == -1); + resetView(); +} + +void CFilesManager::debug(CScreenManager *screenManager) { + warning("TODO: CFilesManager::debug"); +} + +void CFilesManager::resetView() { + if (_gameManager) { + _gameManager->_gameState.setMode(GSMODE_INTERACTIVE); + _gameManager->initBounds(); + } +} + +void CFilesManager::fn4(const CString &name) { + warning("TODO: CFilesManager::fn4"); +} + +void CFilesManager::preload(const CString &name) { + // We don't currently do any preloading of resources +} + +Common::SeekableReadStream *CFilesManager::getResource(const CString &str) { + ResourceEntry resEntry = _resources[str]; + _datFile.seek(resEntry._offset); + + return _datFile.readStream(resEntry._size); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/files_manager.h b/engines/titanic/support/files_manager.h new file mode 100644 index 0000000000..ec0c7fc008 --- /dev/null +++ b/engines/titanic/support/files_manager.h @@ -0,0 +1,109 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FILES_MANAGER_H +#define TITANIC_FILES_MANAGER_H + +#include "common/hashmap.h" +#include "titanic/core/list.h" +#include "titanic/support/screen_manager.h" + +namespace Titanic { + +class CGameManager; + +class CFilesManagerList : public List<ListItem> { +}; + +class CFilesManager { + struct ResourceEntry { + uint _offset; + uint _size; + + ResourceEntry() : _offset(0), _size(0) {} + ResourceEntry(uint offset, uint size) : _offset(offset), _size(size) {} + }; + typedef Common::HashMap<Common::String, ResourceEntry> ResourceHash; +private: + CGameManager *_gameManager; + Common::File _datFile; + ResourceHash _resources; + CFilesManagerList _list; + CString _string1; + CString _string2; + int _field0; + int _drive; + int _field18; + int _field1C; + int _field3C; + const CString _assetsPath; +private: + void loadResourceIndex(); +public: + CFilesManager(); + ~CFilesManager(); + + /** + * Sets the game manager + */ + void setGameManager(CGameManager *gameManager) { + _gameManager = gameManager; + } + + /** + * Returns true if a file of the given name exists + */ + static bool fileExists(const CString &name); + + /** + * Scans for a file with a matching name + */ + bool scanForFile(const CString &name); + + /** + * Handles displaying a load drive view if necessary + */ + void loadDrive(); + + void debug(CScreenManager *screenManager); + + /** + * Resets the view being displayed + */ + void resetView(); + + void fn4(const CString &name); + + /** + * Preloads and caches a file for access shortly + */ + void preload(const CString &name); + + /** + * Get a resource from the executable + */ + Common::SeekableReadStream *getResource(const CString &str); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FILES_MANAGER_H */ diff --git a/engines/titanic/support/font.cpp b/engines/titanic/support/font.cpp new file mode 100644 index 0000000000..69c0efe504 --- /dev/null +++ b/engines/titanic/support/font.cpp @@ -0,0 +1,281 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/support/font.h" +#include "titanic/support/files_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +STFont::STFont() { + _dataPtr = nullptr; + _dataSize = 0; + _fontHeight = 0; + _dataWidth = 0; + _fontR = _fontG = _fontB = 0; +} + +STFont::~STFont() { + delete[] _dataPtr; +} + +void STFont::load(int fontNumber) { + assert(!_dataPtr); + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource( + CString::format("STFONT/%d", fontNumber)); + if (!stream) + error("Could not locate the specified font"); + + _fontHeight = stream->readUint32LE(); + _dataWidth = stream->readUint32LE(); + for (uint idx = 0; idx < 256; ++idx) + _chars[idx]._width = stream->readUint32LE(); + for (uint idx = 0; idx < 256; ++idx) + _chars[idx]._offset = stream->readUint32LE(); + + _dataSize = stream->readUint32LE(); + _dataPtr = new byte[_dataSize]; + stream->read(_dataPtr, _dataSize); + + delete stream; +} + +void STFont::setColor(byte r, byte g, byte b) { + _fontR = r; + _fontG = g; + _fontB = b; +} + +uint16 STFont::getColor() const { + return g_system->getScreenFormat().RGBToColor(_fontR, _fontG, _fontB); +} + +int STFont::getTextBounds(const CString &str, int maxWidth, Point *sizeOut) const { + Point textSize; + + // Reset output dimensions if provided + if (sizeOut) + *sizeOut = Point(0, 0); + + if (_fontHeight == 0 || !_dataPtr) + // No font, so return immediately + return 0; + + // Loop through the characters of the string + if (!str.empty()) { + for (const char *strP = str.c_str(); *strP; ++strP) { + if (*strP == TEXTCMD_NPC) { + strP += 3; + } else if (*strP == TEXTCMD_SET_COLOR) { + strP += 4; + } else { + if (*strP == ' ') { + // Check fo rline wrapping + checkLineWrap(textSize, maxWidth, strP); + } + + extendBounds(textSize, *strP, maxWidth); + } + } + } + + if (sizeOut) + *sizeOut = textSize; + + return textSize.y + _fontHeight; +} + +int STFont::stringWidth(const CString &text) const { + if (text.empty()) + return 0; + + const char *srcP = text.c_str(); + int total = 0; + char c; + while ((c = *srcP++)) { + if (c == 26) { + // Skip over command parameter bytes + srcP += 3; + } else if (c == TEXTCMD_SET_COLOR) { + // Skip over command parameter bytes + srcP += 4; + } else if (c != '\n') { + total += _chars[(byte)c]._width; + } + } + + return total; +} + +int STFont::writeString(CVideoSurface *surface, const Rect &rect1, const Rect &destRect, + int yOffset, const CString &str, CTextCursor *textCursor) { + if (!_fontHeight || !_dataPtr) + return -1; + + Point textSize(0, -yOffset); + Rect destBounds = destRect; + destBounds.constrain(rect1); + if (destBounds.isEmpty()) + return -1; + + const char *endP = nullptr; + const char *strEndP = str.c_str() + str.size() - 1; + for (const char *srcP = str.c_str(); *srcP; ++srcP) { + if (*srcP == TEXTCMD_NPC) { + srcP += 3; + } else if (*srcP == TEXTCMD_SET_COLOR) { + // Change the color used for characters + byte r = *++srcP; + byte g = *++srcP; + byte b = *++srcP; + ++srcP; + setColor(r, g, b); + } else { + if (*srcP == ' ') { + // Check fo rline wrapping + checkLineWrap(textSize, rect1.width(), srcP); + if (!*srcP) + return endP - str.c_str(); + } + + if (*srcP != '\n') { + WriteCharacterResult result = writeChar(surface, *srcP, textSize, rect1, &destBounds); + if (result == WC_OUTSIDE_BOTTOM) + return endP - str.c_str(); + else if (result == WC_IN_BOUNDS) + endP = srcP; + } + + if (srcP < strEndP) + extendBounds(textSize, *srcP, rect1.width()); + } + } + + if (textCursor && textCursor->getMode() == -2) { + Point cursorPos(rect1.left + textSize.x, rect1.top + textSize.y); + textCursor->setPos(cursorPos); + } + + return endP ? endP - str.c_str() : 0; +} + +WriteCharacterResult STFont::writeChar(CVideoSurface *surface, unsigned char c, const Point &pt, + const Rect &destRect, const Rect *srcRect) { + if (c == 233) + c = '$'; + + Rect tempRect; + tempRect.left = _chars[c]._offset; + tempRect.right = _chars[c]._offset + _chars[c]._width; + tempRect.top = 0; + tempRect.bottom = _fontHeight; + Point destPos(pt.x + destRect.left, pt.y + destRect.top); + + if (srcRect->isEmpty()) + srcRect = &destRect; + if (destPos.y > srcRect->bottom) + return WC_OUTSIDE_BOTTOM; + + if ((destPos.y + tempRect.height()) > srcRect->bottom) { + tempRect.bottom += tempRect.top - destPos.y; + } + + if (destPos.y < srcRect->top) { + if ((tempRect.height() + destPos.y) < srcRect->top) + return WC_OUTSIDE_TOP; + + tempRect.top += srcRect->top - destPos.y; + destPos.y = srcRect->top; + } + + if (destPos.x < srcRect->left) { + if ((tempRect.width() + destPos.x) < srcRect->left) + return WC_OUTSIDE_LEFT; + + tempRect.left += srcRect->left - destPos.x; + destPos.x = srcRect->left; + } else { + if ((tempRect.width() + destPos.x) > srcRect->right) { + if (destPos.x > srcRect->right) + return WC_OUTSIDE_RIGHT; + + tempRect.right += srcRect->left - destPos.x; + } + } + + copyRect(surface, destPos, tempRect); + return WC_IN_BOUNDS; +} + +void STFont::copyRect(CVideoSurface *surface, const Point &pt, Rect &rect) { + if (surface->lock()) { + uint16 *lineP = surface->getBasePtr(pt.x, pt.y); + uint16 color = getColor(); + + for (int yp = rect.top; yp < rect.bottom; ++yp, lineP += surface->getWidth()) { + uint16 *destP = lineP; + for (int xp = rect.left; xp < rect.right; ++xp, ++destP) { + const byte *srcP = _dataPtr + yp * _dataWidth + xp; + surface->changePixel(destP, &color, *srcP >> 3, true); + } + } + + surface->unlock(); + } +} + +void STFont::extendBounds(Point &textSize, byte c, int maxWidth) const { + textSize.x += _chars[c]._width; + + if (c == '\n' || textSize.x > maxWidth) { + textSize.x = 0; + textSize.y += _fontHeight; + } +} + +void STFont::checkLineWrap(Point &textSize, int maxWidth, const char *&str) const { + bool flag = false; + int totalWidth = 0; + for (const char *srcPtr = str; *srcPtr && *srcPtr != ' '; ++srcPtr) { + if (*srcPtr == ' ' && flag) + break; + + if (*srcPtr == TEXTCMD_NPC) { + srcPtr += 3; + } else if (*srcPtr == TEXTCMD_SET_COLOR) { + srcPtr += 4; + } else { + totalWidth += _chars[(byte)*srcPtr]._width; + flag = true; + } + } + + if ((textSize.x + totalWidth) >= maxWidth && totalWidth < maxWidth) { + // Word wrap + textSize.x = 0; + textSize.y += _fontHeight; + ++str; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/font.h b/engines/titanic/support/font.h new file mode 100644 index 0000000000..591fb4661c --- /dev/null +++ b/engines/titanic/support/font.h @@ -0,0 +1,123 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_FONT_H +#define TITANIC_FONT_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "titanic/support/rect.h" +#include "titanic/support/string.h" +#include "titanic/support/text_cursor.h" + +namespace Titanic { + +enum TextCommand { TEXTCMD_NPC = 26, TEXTCMD_SET_COLOR = 27 }; + +enum WriteCharacterResult { + WC_IN_BOUNDS = 0, WC_OUTSIDE_TOP = -1, WC_OUTSIDE_BOTTOM = -2, + WC_OUTSIDE_LEFT = -3, WC_OUTSIDE_RIGHT = -4 +}; + +class CVideoSurface; + +class STFont { + struct CharEntry { + uint _width; + uint _offset; + }; +private: + /** + * Copys a rectangle representing a character in the font data to + * a given destination position in the surface + */ + void copyRect(CVideoSurface *surface, const Common::Point &destPos, + Rect &srcRect); + + /** + * Write a character + */ + WriteCharacterResult writeChar(CVideoSurface *surface, unsigned char c, + const Common::Point &pt, const Rect &destRect, const Rect *srcRect); + + /** + * Extends a passed text area by the space required for + * the given character + */ + void extendBounds(Point &textSize, byte c, int maxWidth) const; + + /** + * Called at spacing between words, checks for line wrapping + */ + void checkLineWrap(Point &textSize, int maxWidth, const char *&str) const; +public: + byte *_dataPtr; + size_t _dataSize; + int _fontHeight; + uint _dataWidth; + CharEntry _chars[256]; + byte _fontR, _fontG, _fontB; +public: + STFont(); + ~STFont(); + + /** + * Load a specified font + */ + void load(int fontNumber); + + /** + * Return the width in pixels of the specified text + */ + int stringWidth(const CString &text) const; + + /** + * Write a string to the specified surface + * @returns The index of the last character that was visible + * with the drawing area + */ + int writeString(CVideoSurface *surface, const Rect &rect1, const Rect &destRect, + int yOffset, const CString &str, CTextCursor *textCursor); + + /** + * Get the text area a string will fit into + * @param str String + * @param maxWidth Maximum width in pixels + * @param sizeOut Optional pointer to output size (width, height) + * @returns Required height + */ + int getTextBounds(const CString &str, int maxWidth, Point *sizeOut) const; + + /** + * Sets the font color + */ + void setColor(byte r, byte g, byte b); + + /** + * Gets the font color + */ + uint16 getColor() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_FONT_H */ diff --git a/engines/titanic/support/image.cpp b/engines/titanic/support/image.cpp new file mode 100644 index 0000000000..1e936b6940 --- /dev/null +++ b/engines/titanic/support/image.cpp @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/image.h" +#include "titanic/titanic.h" +#include "image/bmp.h" + +namespace Titanic { + +void Image::load(const CString &resName) { + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(resName); + loadBitmap(*stream); + delete stream; +} + +void Image::loadBitmap(Common::SeekableReadStream &s) { + ::Image::BitmapDecoder decoder; + decoder.loadStream(s); + const Graphics::Surface *src = decoder.getSurface(); + Graphics::PixelFormat scrFormat = g_system->getScreenFormat(); + + if (src->format == scrFormat) { + create(src->w, src->h, scrFormat); + blitFrom(*src); + } else { + // Convert the loaded surface to the screen surface format + const byte *palette = decoder.getPalette(); + Graphics::Surface *surface = src->convertTo(scrFormat, palette); + create(surface->w, surface->h, scrFormat); + blitFrom(*surface); + + surface->free(); + delete surface; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/image.h b/engines/titanic/support/image.h new file mode 100644 index 0000000000..9876f15c40 --- /dev/null +++ b/engines/titanic/support/image.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_IMAGE_H +#define TITANIC_IMAGE_H + +#include "common/stream.h" +#include "graphics/managed_surface.h" +#include "titanic/support/string.h" + +namespace Titanic { + +class Image : public Graphics::ManagedSurface { +private: + void loadBitmap(Common::SeekableReadStream &s); +public: + virtual ~Image() {} + + void load(const CString &resName); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_IMAGE_H */ diff --git a/engines/titanic/support/image_decoders.cpp b/engines/titanic/support/image_decoders.cpp new file mode 100644 index 0000000000..495d1d0982 --- /dev/null +++ b/engines/titanic/support/image_decoders.cpp @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/image_decoders.h" + +namespace Titanic { + +void CJPEGDecode::decode(OSVideoSurface &surface, const CString &name) { + // Open up the resource + StdCWadFile file; + file.open(name); + + // Use the ScucmmVM deoder to decode it + loadStream(*file.readStream()); + const Graphics::Surface *srcSurf = getSurface(); + + // Resize the surface if necessary + if (!surface.hasSurface() || surface.getWidth() != srcSurf->w + || surface.getHeight() != srcSurf->h) + surface.recreate(srcSurf->w, srcSurf->h); + + // Convert the decoded surface to the correct pixel format, and then copy it over + surface.lock(); + Graphics::Surface *convertedSurface = srcSurf->convertTo(surface._rawSurface->format); + + Common::copy((byte *)convertedSurface->getPixels(), (byte *)convertedSurface->getPixels() + + surface.getPitch() * surface.getHeight(), (byte *)surface._rawSurface->getPixels()); + + convertedSurface->free(); + delete convertedSurface; + surface.unlock(); +} + +/*------------------------------------------------------------------------*/ + +void CTargaDecode::decode(OSVideoSurface &surface, const CString &name) { + // Open up the resource + StdCWadFile file; + file.open(name); + + // Use the ScucmmVM deoder to decode it + loadStream(*file.readStream()); + const Graphics::Surface *srcSurf = getSurface(); + + // Resize the surface if necessary + if (!surface.hasSurface() || surface.getWidth() != srcSurf->w + || surface.getHeight() != srcSurf->h) + surface.recreate(srcSurf->w, srcSurf->h); + + // Convert the decoded surface to the correct pixel format, and then copy it over + surface.lock(); + Graphics::Surface *convertedSurface = srcSurf->convertTo(surface._rawSurface->format); + + Common::copy((byte *)convertedSurface->getPixels(), (byte *)convertedSurface->getPixels() + + surface.getPitch() * surface.getHeight(), (byte *)surface._rawSurface->getPixels()); + + convertedSurface->free(); + delete convertedSurface; + surface.unlock(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/image_decoders.h b/engines/titanic/support/image_decoders.h new file mode 100644 index 0000000000..b824b786a7 --- /dev/null +++ b/engines/titanic/support/image_decoders.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_IMAGE_DECODERS_H +#define TITANIC_IMAGE_DECODERS_H + +#include "image/jpeg.h" +#include "image/tga.h" +#include "titanic/support/string.h" +#include "titanic/support/simple_file.h" +#include "titanic/support/video_surface.h" + +namespace Titanic { + +class CJPEGDecode : public Image::JPEGDecoder { +public: + /** + * Decode the image file onto the passed surface + */ + void decode(OSVideoSurface &surface, const CString &name); +}; + +class CTargaDecode : public Image::TGADecoder { +public: + /** + * Decode the image file onto the passed surface + */ + void decode(OSVideoSurface &surface, const CString &name); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_IMAGE_DECODERS_H */ diff --git a/engines/titanic/support/mouse_cursor.cpp b/engines/titanic/support/mouse_cursor.cpp new file mode 100644 index 0000000000..d6a42823f5 --- /dev/null +++ b/engines/titanic/support/mouse_cursor.cpp @@ -0,0 +1,135 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/memstream.h" +#include "common/textconsole.h" +#include "graphics/cursorman.h" +#include "titanic/support/mouse_cursor.h" +#include "titanic/support/movie.h" +#include "titanic/support/screen_manager.h" +#include "titanic/titanic.h" +#include "titanic/support/video_surface.h" +#include "titanic/core/resource_key.h" + +namespace Titanic { + +static const int CURSOR_DATA[NUM_CURSORS][4] = { + { 1, 136, 19, 18 }, + { 2, 139, 1, 1 }, + { 3, 140, 32, 1 }, + { 4, 137, 13, 0 }, + { 5, 145, 13, 0 }, + { 6, 144, 13, 22 }, + { 7, 137, 14, 0 }, + { 8, 148, 22, 40 }, + { 9, 136, 19, 18 }, + { 10, 143, 11, 11 }, + { 11, 146, 11, 11 }, + { 12, 136, 19, 18 }, + { 13, 136, 19, 25 }, + { 14, 136, 13, 22 }, + { 15, 138, 20, 28 } +}; + +CMouseCursor::CursorEntry::~CursorEntry() { + delete _videoSurface; + delete _frameSurface; +} + +CMouseCursor::CMouseCursor(CScreenManager *screenManager) : + _screenManager(screenManager), _cursorId(CURSOR_HOURGLASS), + _setCursorCount(0), _fieldE4(0), _fieldE8(0) { + loadCursorImages(); + setCursor(CURSOR_ARROW); +} + +CMouseCursor::~CMouseCursor() { +} + +void CMouseCursor::loadCursorImages() { + const CResourceKey key("ycursors.avi"); + g_vm->_filesManager->fn4(key.getString()); + + // Iterate through getting each cursor + for (int idx = 0; idx < NUM_CURSORS; ++idx) { + assert(CURSOR_DATA[idx][0] == (idx + 1)); + _cursors[idx]._centroid = Common::Point(CURSOR_DATA[idx][2], + CURSOR_DATA[idx][3]); + + // Create the surface + CVideoSurface *surface = _screenManager->createSurface(64, 64); + _cursors[idx]._videoSurface = surface; + + // Open the cursors video and move to the given frame + OSMovie movie(key, surface); + movie.setFrame(idx); + + Graphics::ManagedSurface *frameSurface = movie.duplicateFrame(); + _cursors[idx]._frameSurface = frameSurface; + surface->setMovieFrameSurface(frameSurface); + } +} + +void CMouseCursor::show() { + CursorMan.showMouse(true); +} + +void CMouseCursor::hide() { + CursorMan.showMouse(false); +} + +void CMouseCursor::setCursor(CursorId cursorId) { + ++_setCursorCount; + + if (cursorId != _cursorId) { + CursorEntry &ce = _cursors[cursorId - 1]; + CVideoSurface &surface = *ce._videoSurface; + surface.lock(); + + CursorMan.replaceCursor(surface.getPixels(), surface.getWidth(), surface.getHeight(), + ce._centroid.x, ce._centroid.y, 0, false, &g_vm->_screen->format); + surface.unlock(); + + _cursorId = cursorId; + } +} + +void CMouseCursor::update() { + // No implementation needed +} + +void CMouseCursor::lockE4() { + _fieldE4 = 0; + CScreenManager::_screenManagerPtr->_inputHandler->incLockCount(); +} + +void CMouseCursor::unlockE4() { + _fieldE4 = 1; + _fieldE8 = 0; + CScreenManager::_screenManagerPtr->_inputHandler->decLockCount(); +} + +void CMouseCursor::saveState(int v1, int v2, int v3) { + // TODO +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/mouse_cursor.h b/engines/titanic/support/mouse_cursor.h new file mode 100644 index 0000000000..7a81ad43fa --- /dev/null +++ b/engines/titanic/support/mouse_cursor.h @@ -0,0 +1,114 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOUSE_CURSOR_H +#define TITANIC_MOUSE_CURSOR_H + +#include "common/scummsys.h" +#include "common/rect.h" +#include "graphics/managed_surface.h" + +namespace Titanic { + +#define NUM_CURSORS 15 + +enum CursorId { + CURSOR_ARROW = 1, + CURSOR_MOVE_LEFT = 2, + CURSOR_MOVE_RIGHT = 3, + CURSOR_MOVE_FORWARD = 4, + CURSOR_MOVE_UP = 5, + CURSOR_MOVE_DOWN1 = 6, + CURSOR_MOVE_FORWARD2 = 7, + CURSOR_HAND = 8, + CURSOR_ACTIVATE = 9, + CURSOR_INVALID = 10, + CURSOR_MAGNIFIER = 11, + CURSOR_IGNORE = 12, + CURSOR_BACKWARDS = 13, + CURSOR_DOWN = 14, + CURSOR_HOURGLASS = 15 +}; + +class CScreenManager; +class CVideoSurface; + +class CMouseCursor { + struct CursorEntry { + CVideoSurface *_videoSurface; + Graphics::ManagedSurface *_frameSurface; + Common::Point _centroid; + + CursorEntry() : _videoSurface(nullptr), _frameSurface(nullptr) {} + ~CursorEntry(); + }; +private: + CScreenManager *_screenManager; + CursorId _cursorId; + CursorEntry _cursors[NUM_CURSORS]; + uint _setCursorCount; + int _fieldE4; + int _fieldE8; + + /** + * Load the images for each cursor + */ + void loadCursorImages(); +public: + CMouseCursor(CScreenManager *screenManager); + ~CMouseCursor(); + + /** + * Make the mouse cursor visible + */ + void show(); + + /** + * Hide the mouse cursor + */ + void hide(); + + /** + * Set the cursor + */ + void setCursor(CursorId cursorId); + + /** + * Updates the mouse cursor + */ + void update(); + + /** + * Returns the number of times the cursor has been set + */ + uint getChangeCount() const { return _setCursorCount; } + + void lockE4(); + void unlockE4(); + + void saveState(int v1, int v2, int v3); +}; + + +} // End of namespace Titanic + +#endif /* TITANIC_MOUSE_CURSOR_H */ diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp new file mode 100644 index 0000000000..3bb9fb88cf --- /dev/null +++ b/engines/titanic/support/movie.cpp @@ -0,0 +1,218 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/movie.h" +#include "titanic/support/avi_surface.h" +#include "titanic/sound/sound_manager.h" +#include "titanic/messages/messages.h" +#include "titanic/titanic.h" + +namespace Titanic { + +#define CLIP_WIDTH 600 +#define CLIP_WIDTH_REDUCED (CLIP_WIDTH / 2) +#define CLIP_HEIGHT 340 +#define CLIP_HEIGHT_REDUCED (CLIP_HEIGHT / 2) + +CMovieList *CMovie::_playingMovies; +CVideoSurface *CMovie::_movieSurface; + +CMovie::CMovie() : ListItem(), _handled(false), _hasVideoFrame(false), + _hasAudioTiming(false) { +} + +CMovie::~CMovie() { + removeFromPlayingMovies(); +} + +void CMovie::init() { + _playingMovies = new CMovieList(); + _movieSurface = nullptr; +} + +void CMovie::deinit() { + // Delete each movie in turn + for (CMovieList::iterator i = _playingMovies->begin(); i != _playingMovies->end(); ) { + // We need to increment iterator before deleting movie, + // since the CMovie destructor calls removeFromPlayingMovies + CMovie *movie = *i; + ++i; + delete movie; + } + + delete _playingMovies; + delete _movieSurface; +} + +void CMovie::addToPlayingMovies() { + if (!isActive()) + _playingMovies->push_back(this); +} + +void CMovie::removeFromPlayingMovies() { + _playingMovies->remove(this); +} + +bool CMovie::isActive() const { + return _playingMovies->contains(this); +} + +bool CMovie::hasVideoFrame() { + if (_hasVideoFrame) { + _hasVideoFrame = 0; + return true; + } else { + return false; + } +} + +/*------------------------------------------------------------------------*/ + +OSMovie::OSMovie(const CResourceKey &name, CVideoSurface *surface) : + _aviSurface(name), _videoSurface(surface) { + _field18 = 0; + _field24 = 0; + _field28 = 0; + _field2C = 0; + + surface->resize(_aviSurface.getWidth(), _aviSurface.getHeight()); + _aviSurface.setVideoSurface(surface); +} + +OSMovie::~OSMovie() { +} + +void OSMovie::play(uint flags, CGameObject *obj) { + _aviSurface.play(flags, obj); + + if (_aviSurface.isPlaying()) + movieStarted(); +} + +void OSMovie::play(uint startFrame, uint endFrame, uint flags, CGameObject *obj) { + _aviSurface.play(startFrame, endFrame, flags, obj); + + if (_aviSurface.isPlaying()) + movieStarted(); +} + +void OSMovie::play(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj) { + _aviSurface.play(startFrame, endFrame, initialFrame, flags, obj); + + if (_aviSurface.isPlaying()) + movieStarted(); +} + +void OSMovie::playClip(const Point &drawPos, uint startFrame, uint endFrame) { + if (!_movieSurface) + _movieSurface = CScreenManager::_screenManagerPtr->createSurface(600, 340); + + bool widthLess = _videoSurface->getWidth() < 600; + bool heightLess = _videoSurface->getHeight() < 340; + Rect r(drawPos.x, drawPos.y, + drawPos.x + (widthLess ? CLIP_WIDTH_REDUCED : CLIP_WIDTH), + drawPos.y + (heightLess ? CLIP_HEIGHT_REDUCED : CLIP_HEIGHT) + ); + + uint timePerFrame = (uint)(1000.0 / _aviSurface._frameRate); + + for (; endFrame >= startFrame; ++startFrame) { + // Set the frame + _aviSurface.setFrame(startFrame); + + // TODO: See if we need to do anything further here. The original had a bunch + // of calls and using of the _movieSurface; perhaps to allow scaling down + // videos to half-size + if (widthLess || heightLess) + warning("Not properly reducing clip size: %d %d", r.width(), r.height()); + + // Wait for the next frame, unless the user interrupts the clip + if (g_vm->_events->waitForPress(timePerFrame)) + break; + } +} + +void OSMovie::stop() { + _aviSurface.stop(); + removeFromPlayingMovies(); +} + +void OSMovie::addEvent(int frameNumber, CGameObject *obj) { + if (_aviSurface.addEvent(frameNumber, obj)) { + CMovieFrameMsg frameMsg(frameNumber, 0); + frameMsg.execute(obj); + } +} + +void OSMovie::setFrame(uint frameNumber) { + _aviSurface.setFrame(frameNumber); + _videoSurface->setMovieFrameSurface(_aviSurface.getSecondarySurface()); +} + +bool OSMovie::handleEvents(CMovieEventList &events) { + if (!_aviSurface.isPlaying()) + return false; + if (!_aviSurface.isNextFrame()) + return _aviSurface.isPlaying(); + + // Handle updating the frame + while (_aviSurface.isPlaying() && _aviSurface.isNextFrame()) { + _aviSurface.handleEvents(events); + _videoSurface->setMovieFrameSurface(_aviSurface.getSecondarySurface()); + } + + // Flag there's a video frame + _hasVideoFrame = true; + + return _aviSurface.isPlaying(); +} + +const CMovieRangeInfoList *OSMovie::getMovieRangeInfo() const { + return _aviSurface.getMovieRangeInfo(); +} + +void OSMovie::setSoundManager(CSoundManager *soundManager) { + _aviSurface._soundManager = soundManager; +} + +int OSMovie::getFrame() const { + return _aviSurface.getFrame(); +} + +void OSMovie::movieStarted() { + //if (_aviSurface._hasAudio) + // _aviSurface._soundManager->movieStarted(); + + // Register the movie in the playing list + addToPlayingMovies(); + _hasVideoFrame = true; +} + +void OSMovie::setFrameRate(double rate) { + _aviSurface.setFrameRate(rate); +} + +Graphics::ManagedSurface *OSMovie::duplicateFrame() const { + return _aviSurface.duplicateSecondaryFrame(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h new file mode 100644 index 0000000000..2d1c264f03 --- /dev/null +++ b/engines/titanic/support/movie.h @@ -0,0 +1,237 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVIE_H +#define TITANIC_MOVIE_H + +#include "common/list.h" +#include "video/video_decoder.h" +#include "titanic/core/list.h" +#include "titanic/core/resource_key.h" +#include "titanic/support/avi_surface.h" +#include "titanic/support/movie_range_info.h" + +namespace Titanic { + +class CGameObject; +class CMovie; +class CSoundManager; +class CVideoSurface; + +class CMovieList : public List<CMovie> { +public: +}; + +class CMovie : public ListItem { +protected: + /** + * Adds the movie to the list of currently playing movies + */ + void addToPlayingMovies(); +public: + bool _handled; + bool _hasVideoFrame; + bool _hasAudioTiming; +public: + static CMovieList *_playingMovies; + static CVideoSurface *_movieSurface; + + /** + * Initializes statics + */ + static void init(); + + /** + * Deinitializes statics + */ + static void deinit(); +public: + CMovie(); + virtual ~CMovie(); + + /** + * Starts playing the movie + */ + virtual void play(uint flags, CGameObject *obj) = 0; + + /** + * Starts playing the movie + */ + virtual void play(uint startFrame, uint endFrame, uint flags, CGameObject *obj) = 0; + + /** + * Starts playing the movie + */ + virtual void play(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj) = 0; + + /** + * Plays a sub-section of a movie + */ + virtual void playClip(const Point &drawPos, uint startFrame, uint endFrame) = 0; + + /** + * Stops the movie + */ + virtual void stop() = 0; + + /** + * Add a playback event + */ + virtual void addEvent(int frameNumber, CGameObject *obj) = 0; + + /** + * Set the current frame number + */ + virtual void setFrame(uint frameNumber) = 0; + + /** + * Handle any pending movie events + */ + virtual bool handleEvents(CMovieEventList &events) = 0; + + /** + * Return any movie range info associated with the movie + */ + virtual const CMovieRangeInfoList *getMovieRangeInfo() const = 0; + + /** + * Set the sound manager reference + */ + virtual void setSoundManager(CSoundManager *soundManager) = 0; + + /** + * Get the current movie frame + */ + virtual int getFrame() const = 0; + + /** + * Set the frame rate for the movie + */ + virtual void setFrameRate(double rate) = 0; + + /** + * Creates a duplicate of the movie's frame + */ + virtual Graphics::ManagedSurface *duplicateFrame() const = 0; + + /** + * Removes the movie from the list of currently playing movies + */ + void removeFromPlayingMovies(); + + /** + * Returns true if the movie is currently active + */ + bool isActive() const; + + /** + * Returns true if there's a video frame + */ + bool hasVideoFrame(); +}; + +class OSMovie : public CMovie { +private: + AVISurface _aviSurface; + CVideoSurface *_videoSurface; + int _field18; + int _field24; + int _field28; + int _field2C; +private: + /** + * Called when a movie is started playing + */ + void movieStarted(); +public: + OSMovie(const CResourceKey &name, CVideoSurface *surface); + virtual ~OSMovie(); + + /** + * Starts playing the movie + */ + virtual void play(uint flags, CGameObject *obj); + + /** + * Starts playing the movie + */ + virtual void play(uint startFrame, uint endFrame, uint flags, CGameObject *obj); + + /** + * Starts playing the movie + */ + virtual void play(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj); + + /** + * Plays a sub-section of a movie + */ + virtual void playClip(const Point &drawPos, uint startFrame, uint endFrame); + + /** + * Stops the movie + */ + virtual void stop(); + + /** + * Add a playback event + */ + virtual void addEvent(int eventId, CGameObject *obj); + + /** + * Set the current frame number + */ + virtual void setFrame(uint frameNumber); + + /** + * Handle any pending movie events + */ + virtual bool handleEvents(CMovieEventList &events); + + /** + * Get the current frame number + */ + virtual int getFrame() const; + + /** + * Return any movie range info associated with the movie + */ + virtual const CMovieRangeInfoList *getMovieRangeInfo() const; + + /** + * Set the sound manager reference + */ + virtual void setSoundManager(CSoundManager *soundManager); + + /** + * Set the frame rate for the movie + */ + virtual void setFrameRate(double rate); + + /** + * Creates a duplicate of the frame info + */ + virtual Graphics::ManagedSurface *duplicateFrame() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_H */ diff --git a/engines/titanic/support/movie_clip.cpp b/engines/titanic/support/movie_clip.cpp new file mode 100644 index 0000000000..1f2ef66428 --- /dev/null +++ b/engines/titanic/support/movie_clip.cpp @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/movie_clip.h" +#include "titanic/core/game_object.h" + +namespace Titanic { + +CMovieClip::CMovieClip(): ListItem(), _startFrame(0), _endFrame(0) { +} + +CMovieClip::CMovieClip(const CString &name, int startFrame, int endFrame): + ListItem(), _name(name), _startFrame(startFrame), _endFrame(endFrame) { +} + +void CMovieClip::save(SimpleFile *file, int indent) { + file->writeNumberLine(2, indent); + file->writeQuotedLine("Clip", indent); + file->writeQuotedLine(_name, indent); + file->writeNumberLine(_startFrame, indent); + file->writeNumberLine(_endFrame, indent); + + ListItem::save(file, indent); +} + +void CMovieClip::load(SimpleFile *file) { + int val = file->readNumber(); + + switch (val) { + case 1: + // This should never be used + assert(0); + break; + + case 2: + file->readString(); + _name = file->readString(); + _startFrame = file->readNumber(); + _endFrame = file->readNumber(); + break; + + default: + break; + } + + ListItem::load(file); +} + +/*------------------------------------------------------------------------*/ + +CMovieClip *CMovieClipList::findByName(const Common::String &name) const { + for (const_iterator i = begin(); i != end(); ++i) { + CMovieClip *clip = *i; + if (clip->_name == name) + return clip; + } + + return nullptr; +} + +bool CMovieClipList::existsByStart(const CString &name, int startFrame) const { + for (const_iterator i = begin(); i != end(); ++i) { + CMovieClip *clip = *i; + if (clip->_startFrame == startFrame && clip->_name == name) + return true; + } + + return false; +} + +bool CMovieClipList::existsByEnd(const CString &name, int endFrame) const { + for (const_iterator i = begin(); i != end(); ++i) { + CMovieClip *clip = *i; + if (clip->_endFrame == endFrame && clip->_name == name) + return true; + } + + return false; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/movie_clip.h b/engines/titanic/support/movie_clip.h new file mode 100644 index 0000000000..513ed4a339 --- /dev/null +++ b/engines/titanic/support/movie_clip.h @@ -0,0 +1,92 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVIE_CLIP_H +#define TITANIC_MOVIE_CLIP_H + +#include "titanic/core/list.h" + +namespace Titanic { + +enum ClipFlag { + CLIPFLAG_HAS_END_FRAME = 1, + CLIPFLAG_4 = 4, + CLIPFLAG_HAS_START_FRAME = 8, + CLIPFLAG_PLAY = 0x10 +}; + +class CGameObject; + +/** + * Movie clip + */ +class CMovieClip : public ListItem { +private: + Common::List<void *> _items; + CString _string2; + CString _string3; +public: + CString _name; + int _startFrame; + int _endFrame; +public: + CLASSDEF; + CMovieClip(); + CMovieClip(const CString &name, int startFrame, int endFrame); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +/** + * Movie clip list + */ +class CMovieClipList: public List<CMovieClip> { +public: + /** + * Finds and returns a movie clip in the list by name + */ + CMovieClip *findByName(const Common::String &name) const; + + /** + * Returns true if a clip exists in the list with a given name + * and starting frame number + */ + bool existsByStart(const CString &name, int startFrame = 0) const; + + /** + * Returns true if a clip exists in the list with a given name + * and starting frame number + */ + bool existsByEnd(const CString &name, int endFrame = 0) const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_CLIP_H */ diff --git a/engines/titanic/support/movie_event.cpp b/engines/titanic/support/movie_event.cpp new file mode 100644 index 0000000000..5f8a6da019 --- /dev/null +++ b/engines/titanic/support/movie_event.cpp @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/movie_event.h" +#include "titanic/core/game_object.h" + +namespace Titanic { + +CMovieEvent::CMovieEvent() : ListItem(), _type(MET_PLAY), _startFrame(0), + _endFrame(0), _initialFrame(0), _gameObject(nullptr) { +} + +CMovieEvent::CMovieEvent(const CMovieEvent *src) { + _type = src->_type; + _startFrame = src->_startFrame; + _endFrame = src->_endFrame; + _initialFrame = src->_initialFrame; + _gameObject = src->_gameObject; +} + +void CMovieEvent::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + file->writeNumberLine(_startFrame, indent + 1); + file->writeNumberLine(_endFrame, indent + 1); + error("FIXME: Original save/loaded object pointer"); + // file->writeNumberLine(_gameObject, indent + 1); + file->writeNumberLine(_initialFrame, indent + 1); + + ListItem::save(file, indent); +} + +void CMovieEvent::load(SimpleFile *file) { + int val = file->readNumber(); + if (!val) { + _startFrame = file->readNumber(); + _endFrame = file->readNumber(); + file->readNumber(); + error("FIXME: Original save/loaded object pointer"); + _initialFrame = file->readNumber(); + } + + ListItem::load(file); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/movie_event.h b/engines/titanic/support/movie_event.h new file mode 100644 index 0000000000..af93c76a31 --- /dev/null +++ b/engines/titanic/support/movie_event.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVIE_EVENT_H +#define TITANIC_MOVIE_EVENT_H + +#include "titanic/core/list.h" + +namespace Titanic { + +enum MovieEventType { MET_PLAY = 0, MET_MOVIE_END = 1, MET_FRAME = 2 }; + +class CGameObject; + +class CMovieEvent : public ListItem { +public: + MovieEventType _type; + int _startFrame; + int _endFrame; + CGameObject *_gameObject; + int _initialFrame; +public: + CMovieEvent(); + CMovieEvent(const CMovieEvent *src); + virtual ~CMovieEvent() {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +class CMovieEventList : public List<CMovieEvent> { +}; + +class CSharedMovieEventList : public Common::List<CMovieEvent> { +}; + + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_EVENT_H */ diff --git a/engines/titanic/support/movie_manager.cpp b/engines/titanic/support/movie_manager.cpp new file mode 100644 index 0000000000..bfeb081b5c --- /dev/null +++ b/engines/titanic/support/movie_manager.cpp @@ -0,0 +1,35 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/movie_manager.h" +#include "titanic/support/movie.h" +#include "titanic/support/video_surface.h" + +namespace Titanic { + +CMovie *CMovieManager::createMovie(const CResourceKey &key, CVideoSurface *surface) { + CMovie *movie = new OSMovie(key, surface); + movie->setSoundManager(_soundManager); + return movie; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/movie_manager.h b/engines/titanic/support/movie_manager.h new file mode 100644 index 0000000000..2920d909b7 --- /dev/null +++ b/engines/titanic/support/movie_manager.h @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVIE_MANAGER_H +#define TITANIC_MOVIE_MANAGER_H + +#include "titanic/core/list.h" +#include "titanic/core/resource_key.h" +#include "titanic/sound/sound_manager.h" + +namespace Titanic { + +class CMovie; +class CVideoSurface; + +class CMovieManagerBase { +public: + virtual ~CMovieManagerBase() {} + + /** + * Create a new movie and return it + */ + virtual CMovie *createMovie(const CResourceKey &key, CVideoSurface *surface) = 0; +}; + +class CMovieManager : public CMovieManagerBase { +private: + CSoundManager *_soundManager; +public: + CMovieManager() : CMovieManagerBase(), _soundManager(nullptr) {} + virtual ~CMovieManager() {} + + /** + * Create a new movie and return it + */ + virtual CMovie *createMovie(const CResourceKey &key, CVideoSurface *surface); + + /** + * Sets the sound manager that will be attached to all created movies + */ + void setSoundManager(CSoundManager *soundManager) { _soundManager = soundManager; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_MANAGER_H */ diff --git a/engines/titanic/support/movie_range_info.cpp b/engines/titanic/support/movie_range_info.cpp new file mode 100644 index 0000000000..d4d9fc0e2a --- /dev/null +++ b/engines/titanic/support/movie_range_info.cpp @@ -0,0 +1,112 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/movie_range_info.h" +#include "titanic/support/movie_clip.h" +#include "titanic/core/game_object.h" + +namespace Titanic { + +CMovieRangeInfo::CMovieRangeInfo() : ListItem(), _startFrame(0), _endFrame(0) { +} + +CMovieRangeInfo::~CMovieRangeInfo() { + _events.destroyContents(); +} + +CMovieRangeInfo::CMovieRangeInfo(const CMovieRangeInfo *src) : ListItem() { + _startFrame = src->_startFrame; + _endFrame = src->_endFrame; + _initialFrame = src->_initialFrame; + _isReversed = src->_isReversed; + _isRepeat = src->_isRepeat; + + // Duplicate the events list + for (CMovieEventList::const_iterator i = _events.begin(); + i != _events.end(); ++i) { + _events.push_back(new CMovieEvent(*i)); + } +} + +void CMovieRangeInfo::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + file->writeNumberLine(_startFrame, indent + 1); + file->writeNumberLine(_endFrame, indent + 1); + file->writeNumberLine(_initialFrame, indent + 1); + file->writeNumberLine(_isRepeat, indent + 1); + file->writeNumberLine(_isReversed, indent + 1); + _events.save(file, indent + 1); +} + +void CMovieRangeInfo::load(SimpleFile *file) { + int val = file->readNumber(); + if (!val) { + _startFrame = file->readNumber(); + _endFrame = file->readNumber(); + _initialFrame = file->readNumber(); + _isRepeat = file->readNumber(); + _isReversed = file->readNumber(); + _events.load(file); + } +} + +void CMovieRangeInfo::getMovieEnd(CMovieEventList &list) { + for (CMovieEventList::iterator i = _events.begin(); i != _events.end(); ++i) { + CMovieEvent *movieEvent = *i; + if (movieEvent->_type == MET_MOVIE_END) + list.push_back(new CMovieEvent(movieEvent)); + } +} + +void CMovieRangeInfo::getMovieFrame(CMovieEventList &list, int frameNumber) { + for (CMovieEventList::iterator i = _events.begin(); i != _events.end(); ++i) { + CMovieEvent *movieEvent = *i; + if (movieEvent->_type == MET_FRAME && movieEvent->_initialFrame == frameNumber) + list.push_back(new CMovieEvent(movieEvent)); + } +} + +void CMovieRangeInfo::process(CGameObject *owner) { + int flags = 0; + if (_endFrame) + flags |= MOVIE_REPEAT; + if (_startFrame) + flags |= MOVIE_REVERSE; + + for (CMovieEventList::iterator i = _events.begin(); i != _events.end(); ++i) { + CMovieEvent *movieEvent = *i; + if (movieEvent->_type == MET_MOVIE_END) { + flags |= CLIPFLAG_PLAY; + break; + } + } + + owner->playMovie(_startFrame, _endFrame, _initialFrame, flags); + + for (CMovieEventList::iterator i = _events.begin(); i != _events.end(); ++i) { + CMovieEvent *movieEvent = *i; + if (movieEvent->_type == MET_PLAY) + owner->movieEvent(movieEvent->_initialFrame); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/movie_range_info.h b/engines/titanic/support/movie_range_info.h new file mode 100644 index 0000000000..6b13fbadb5 --- /dev/null +++ b/engines/titanic/support/movie_range_info.h @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MOVIE_RANGE_INFO_H +#define TITANIC_MOVIE_RANGE_INFO_H + +#include "video/video_decoder.h" +#include "titanic/core/list.h" +#include "titanic/core/resource_key.h" +#include "titanic/support/movie_event.h" + +namespace Titanic { + +class CGameObject; + +class CMovieRangeInfo : public ListItem { +public: + int _startFrame; + int _endFrame; + int _initialFrame; + bool _isReversed; + bool _isRepeat; + CMovieEventList _events; +public: + CMovieRangeInfo(); + CMovieRangeInfo(const CMovieRangeInfo *src); + virtual ~CMovieRangeInfo(); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Adds an event to the events list + */ + void addEvent(CMovieEvent *movieEvent) { _events.push_back(movieEvent); } + + /** + * Get any movie end events for the range + */ + void getMovieEnd(CMovieEventList &list); + + /** + * Get any movie frame events for a specified frame number + */ + void getMovieFrame(CMovieEventList &list, int frameNumber); + + void process(CGameObject *owner); +}; + +class CMovieRangeInfoList : public List<CMovieRangeInfo> { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MOVIE_RANGE_INFO_H */ diff --git a/engines/titanic/support/rect.cpp b/engines/titanic/support/rect.cpp new file mode 100644 index 0000000000..5fce4402cb --- /dev/null +++ b/engines/titanic/support/rect.cpp @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/rect.h" + +namespace Titanic { + +void Rect::combine(const Rect &r) { + if (isEmpty() || r.isEmpty()) + return; + + Common::Rect::extend(r); +} + +void Rect::constrain(const Rect &r) { + if (!isEmpty()) { + if (r.isEmpty()) { + clear(); + } else { + Common::Rect::clip(r); + } + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/rect.h b/engines/titanic/support/rect.h new file mode 100644 index 0000000000..1661711870 --- /dev/null +++ b/engines/titanic/support/rect.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_RECT_H +#define TITANIC_RECT_H + +#include "common/rect.h" + +namespace Titanic { + +typedef Common::Point Point; + +class Rect : public Common::Rect { +public: + Rect() : Common::Rect() {} + Rect(int16 w, int16 h) : Common::Rect(w, h) {} + Rect(int16 x1, int16 y1, int16 x2, int16 y2) : Common::Rect(x1, y1, x2, y2) {} + + /** + * Returns the top/left corner of the rect as a point + */ + operator const Point() { return Point(left, top); } + + /** + * Clear the rect + */ + void clear() { left = top = right = bottom = 0; } + + /** + * Combine another rect into this one + */ + void combine(const Rect &r); + + /** + * Constrains/clips to the intersection area of the given rect + */ + void constrain(const Rect &r); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_RECT_H */ diff --git a/engines/titanic/support/screen_manager.cpp b/engines/titanic/support/screen_manager.cpp new file mode 100644 index 0000000000..d795f78764 --- /dev/null +++ b/engines/titanic/support/screen_manager.cpp @@ -0,0 +1,326 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/screen_manager.h" +#include "titanic/titanic.h" +#include "titanic/support/video_surface.h" + +namespace Titanic { + +CScreenManager *CScreenManager::_screenManagerPtr; +CScreenManager *CScreenManager::_currentScreenManagerPtr; + +CScreenManager::CScreenManager(TitanicEngine *vm): _vm(vm) { + _screenManagerPtr = nullptr; + _currentScreenManagerPtr = nullptr; + + _frontRenderSurface = nullptr; + _mouseCursor = nullptr; + _textCursor = nullptr; + _inputHandler = nullptr; + _fontNumber = 0; + // TODO: Further initialization + + _screenManagerPtr = this; +} + +CScreenManager::~CScreenManager() { + _screenManagerPtr = nullptr; +} + +void CScreenManager::setWindowHandle(int v) { + // Not needed +} + +bool CScreenManager::resetWindowHandle(int v) { + hideCursor(); + return true; +} + +CScreenManager *CScreenManager::setCurrent() { + if (!_currentScreenManagerPtr) + _currentScreenManagerPtr = _screenManagerPtr; + + return _currentScreenManagerPtr; +} + +void CScreenManager::setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r) { + if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) + _backSurfaces[surfaceNum]._bounds = r; +} + +int CScreenManager::setFontNumber(int fontNumber) { + int oldFontNumber = _fontNumber; + _fontNumber = fontNumber; + return oldFontNumber; +} + +/*------------------------------------------------------------------------*/ + +OSScreenManager::OSScreenManager(TitanicEngine *vm): CScreenManager(vm), + _directDrawManager(vm, false) { + _field48 = 0; + _field4C = 0; + _field50 = 0; + _field54 = 0; +} + +OSScreenManager::~OSScreenManager() { + destroyFrontAndBackBuffers(); + delete _mouseCursor; + delete _textCursor; +} + +void OSScreenManager::setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2) { + assert(bpp == 16); + destroyFrontAndBackBuffers(); + _directDrawManager.initVideo(width, height, bpp, numBackSurfaces); + + _vm->_screen->create(width, height, g_system->getScreenFormat()); + _frontRenderSurface = new OSVideoSurface(this, nullptr); + _frontRenderSurface->setSurface(this, _directDrawManager._mainSurface); + + _backSurfaces.resize(numBackSurfaces); + for (uint idx = 0; idx < numBackSurfaces; ++idx) { + _backSurfaces[idx]._surface = new OSVideoSurface(this, nullptr); + _backSurfaces[idx]._surface->setSurface(this, _directDrawManager._backSurfaces[idx]); + } + + // Load fonts + _fonts[0].load(149); + _fonts[1].load(151); + _fonts[2].load(152); + _fonts[3].load(153); + + // Load the cursors + loadCursors(); +} + +void OSScreenManager::drawCursors() { + // The original did both text and mouse cursor drawing here. + // For ScummVM, we only need to worry about the text cursor + _textCursor->draw(); +} + +DirectDrawSurface *OSScreenManager::getDDSurface(SurfaceNum surfaceNum) { + if (surfaceNum == SURFACE_PRIMARY) + return _directDrawManager._mainSurface; + else if (surfaceNum < (int)_backSurfaces.size()) + return _directDrawManager._backSurfaces[surfaceNum]; + else + return nullptr; +} + +CVideoSurface *OSScreenManager::lockSurface(SurfaceNum surfaceNum) { + CVideoSurface *surface = getSurface(surfaceNum); + surface->lock(); + return surface; +} + +void OSScreenManager::unlockSurface(CVideoSurface *surface) { + surface->unlock(); +} + +CVideoSurface *OSScreenManager::getSurface(SurfaceNum surfaceNum) const { + if (surfaceNum == SURFACE_PRIMARY) + return _frontRenderSurface; + else if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) + return _backSurfaces[surfaceNum]._surface; + else + return nullptr; +} + +void OSScreenManager::fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) { + DirectDrawSurface *surface = getDDSurface(surfaceNum); + if (!surface) + return; + + // If bounds are provided, clip and use them. Otherwise, use entire surface area + Rect surfaceRect(0, 0, surface->getWidth(), surface->getHeight()); + Rect tempRect; + + if (rect) { + tempRect = *rect; + tempRect.clip(surfaceRect); + } else { + tempRect = surfaceRect; + } + + if (tempRect.isValidRect()) + surface->fillRect(&tempRect, r, g, b); +} + +void OSScreenManager::blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, + const Point *destPos, const Rect *srcRect) { + // Get the dest surface + CVideoSurface *destSurface = _frontRenderSurface; + if (surfaceNum < -1) + return; + if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) + destSurface = _backSurfaces[surfaceNum]._surface; + if (!destSurface->hasSurface()) + return; + + Point destPoint = destPos ? *destPos : Point(0, 0); + Rect srcBounds = srcRect ? *srcRect : Rect(0, 0, src->getWidth(), src->getHeight()); + Rect *bounds = &srcBounds; + Rect rect2; + + if (surfaceNum >= 0 && !_backSurfaces[surfaceNum]._bounds.isEmpty()) { + // Perform clipping to the bounds of the back surface + rect2 = srcBounds; + rect2.translate(-srcBounds.left, -srcBounds.top); + rect2.translate(destPoint.x, destPoint.y); + rect2.constrain(_backSurfaces[surfaceNum]._bounds); + + rect2.translate(-destPoint.x, -destPoint.y); + rect2.translate(srcBounds.left, srcBounds.top); + + if (rect2.isEmpty()) + return; + + destPoint.x += rect2.left - srcBounds.left; + destPoint.y += rect2.top - srcBounds.top; + bounds = &rect2; + } + + if (!bounds->isEmpty()) + destSurface->blitFrom(destPoint, src, bounds); +} + +void OSScreenManager::blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v) { + // Get the dest surface + CVideoSurface *destSurface = _frontRenderSurface; + if (surfaceNum < -1) + return; + if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) + destSurface = _backSurfaces[surfaceNum]._surface; + if (!destSurface->hasSurface()) + return; + + if (!rect->isEmpty()) + destSurface->blitFrom(Point(rect->left, rect->top), src, rect); +} + +int OSScreenManager::writeString(int surfaceNum, const Rect &destRect, + int yOffset, const CString &str, CTextCursor *textCursor) { + CVideoSurface *surface; + Rect bounds; + + if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) { + surface = _backSurfaces[surfaceNum]._surface; + bounds = _backSurfaces[surfaceNum]._bounds; + } else if (surfaceNum == -1) { + surface = _frontRenderSurface; + bounds = Rect(0, 0, surface->getWidth(), surface->getHeight()); + } else { + return -1; + } + + return _fonts[_fontNumber].writeString(surface, destRect, bounds, + yOffset, str, textCursor); +} + +int OSScreenManager::writeString(int surfaceNum, const Rect &srcRect, + const Rect &destRect, const CString &str, CTextCursor *textCursor) { + // TODO + return 0; +} + +void OSScreenManager::setFontColor(byte r, byte g, byte b) { + _fonts[_fontNumber].setColor(r, g, b); +} + +int OSScreenManager::getTextBounds(const CString &str, int maxWidth, Point *sizeOut) const { + return _fonts[_fontNumber].getTextBounds(str, maxWidth, sizeOut); +} + +int OSScreenManager::getFontHeight() const { + return _fonts[_fontNumber]._fontHeight; +} + +int OSScreenManager::stringWidth(const CString &str) { + return _fonts[_fontNumber].stringWidth(str); +} + +void OSScreenManager::frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b) { + Rect top(rect.left, rect.top, rect.right, rect.top + 1); + fillRect(surfaceNum, &top, r, g, b); + Rect bottom(rect.left, rect.bottom - 1, rect.right, rect.bottom); + fillRect(surfaceNum, &bottom, r, g, b); + Rect left(rect.left, rect.top, rect.left + 1, rect.bottom); + fillRect(surfaceNum, &left, r, g, b); + Rect right(rect.right - 1, rect.top, rect.right, rect.bottom); +} + +void OSScreenManager::clearSurface(SurfaceNum surfaceNum, Rect *bounds) { + if (surfaceNum == SURFACE_PRIMARY) + _directDrawManager._mainSurface->fill(bounds, 0); + else if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) + _directDrawManager._backSurfaces[surfaceNum]->fill(bounds, 0); +} + +void OSScreenManager::resizeSurface(CVideoSurface *surface, int width, int height) { + DirectDrawSurface *ddSurface = _directDrawManager.createSurface(width, height, 0); + surface->setSurface(this, ddSurface); +} + +CVideoSurface *OSScreenManager::createSurface(int w, int h) { + DirectDrawSurface *ddSurface = _directDrawManager.createSurface(w, h, 0); + return new OSVideoSurface(this, ddSurface); +} + +CVideoSurface *OSScreenManager::createSurface(const CResourceKey &key) { + return new OSVideoSurface(this, key); +} + +void OSScreenManager::showCursor() { + CScreenManager::_screenManagerPtr->_mouseCursor->show(); +} + +void OSScreenManager::hideCursor() { + CScreenManager::_screenManagerPtr->_mouseCursor->hide(); +} + +void OSScreenManager::destroyFrontAndBackBuffers() { + delete _frontRenderSurface; + _frontRenderSurface = nullptr; + + for (uint idx = 0; idx < _backSurfaces.size(); ++idx) + delete _backSurfaces[idx]._surface; + _backSurfaces.clear(); +} + +void OSScreenManager::loadCursors() { + if (_mouseCursor) { + hideCursor(); + delete _mouseCursor; + } + _mouseCursor = new CMouseCursor(this); + showCursor(); + + if (!_textCursor) { + _textCursor = new CTextCursor(this); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/screen_manager.h b/engines/titanic/support/screen_manager.h new file mode 100644 index 0000000000..0736f1393c --- /dev/null +++ b/engines/titanic/support/screen_manager.h @@ -0,0 +1,395 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SCREEN_MANAGER_H +#define TITANIC_SCREEN_MANAGER_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "titanic/support/direct_draw.h" +#include "titanic/support/font.h" +#include "titanic/input_handler.h" +#include "titanic/support/mouse_cursor.h" +#include "titanic/support/text_cursor.h" +#include "titanic/support/video_surface.h" +#include "titanic/core/resource_key.h" + +namespace Titanic { + +/** + * The original used page flipping with one primary and one back buffer. + * Since we don't need that in ScummVM, the back buffer number below is + * remapped to the primary surface + */ +enum SurfaceNum { + SURFACE_PRIMARY = -1, // Surface 0 + SURFACE_BACKBUFFER = -1 // Surface -1 +}; + +class TitanicEngine; + +class CScreenManager { + struct VideoSurfaceEntry { + CVideoSurface *_surface; + Rect _bounds; + }; +protected: + TitanicEngine *_vm; +public: + static CScreenManager *_screenManagerPtr; + static CScreenManager *_currentScreenManagerPtr; + + /** + * Set the current screen manager + */ + static CScreenManager *setCurrent(); +public: + Common::Array<VideoSurfaceEntry> _backSurfaces; + CVideoSurface *_frontRenderSurface; + CMouseCursor *_mouseCursor; + CTextCursor *_textCursor; + CInputHandler *_inputHandler; + int _fontNumber; +public: + CScreenManager(TitanicEngine *vm); + virtual ~CScreenManager(); + + void fn1() {} + void fn2() {} + + virtual void setWindowHandle(int v); + virtual bool resetWindowHandle(int v); + + /** + * Sets the video mode + */ + virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2) = 0; + + /** + * Handles drawing the cursors + */ + virtual void drawCursors() = 0; + + /** + * Locks a specified surface number for access and returns a pointer to it + */ + virtual CVideoSurface *lockSurface(SurfaceNum surfaceNum) = 0; + + /** + * Unlocks a previously locked surface + */ + virtual void unlockSurface(CVideoSurface *surface) = 0; + + /** + * Gets a specified surface number + */ + virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const = 0; + + /** + * Return the front render surface + */ + virtual CVideoSurface *getFrontRenderSurface() const = 0; + + /** + * Fill an area with a specific color + */ + virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b) = 0; + + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos = nullptr, + const Rect *srcRect = nullptr) = 0; + + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0) = 0; + + /** + * Write a string + * @param surfaceNum Destination surface + * @param destRect Bounds within dest surface + * @param yOffset Y offset for drawing, to allow for parts of + * the text to be scrolled off-screen + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &destRect, + int yOffset, const CString &str, CTextCursor *textCursor) = 0; + + /** + * Write a string + * @param surfaceNum Destination surface + * @param srcRect Drawing area + * @param destRect Bounds of dest surface + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &srcRect, + const Rect &destRect, const CString &str, CTextCursor *textCursor) = 0; + + /** + * Set the font color + */ + virtual void setFontColor(byte r, byte g, byte b) = 0; + + /** + * Get the text area a string will fit into + * @param str String + * @param maxWidth Maximum width in pixels + * @param sizeOut Optional pointer to output size + * @returns Required height + */ + virtual int getTextBounds(const CString &str, int maxWidth, Point *sizeOut = nullptr) const = 0; + + /** + * Get the current font height + */ + virtual int getFontHeight() const = 0; + + /** + * Returns the width of a given string in pixels + */ + virtual int stringWidth(const CString &str) = 0; + + /** + * Draws a frame enclosing the specified area + */ + virtual void frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b) = 0; + + /** + * Clear a portion of a specified surface + */ + virtual void clearSurface(SurfaceNum surfaceNum, Rect *_bounds) = 0; + + /** + * Resize the passed surface + */ + virtual void resizeSurface(CVideoSurface *surface, int width, int height) = 0; + + /** + * Creates a surface of a given size + */ + virtual CVideoSurface *createSurface(int w, int h) = 0; + + /** + * Creates a surface from a specified resource + */ + virtual CVideoSurface *createSurface(const CResourceKey &key) = 0; + + /** + * Get the top-left corner of the screen in global screen co-ordinates + * For ScummVM, this is always (0, 0), even in Windowed mode + */ + virtual Point getScreenTopLeft() { return Point(0, 0); } + + /** + * Waits for a vertical screen sync + * For ScummVM, this can be safely ignored + */ + virtual void waitForVSync() {} + + /** + * Show the mouse cursor + */ + virtual void showCursor() = 0; + + /** + * Hide the mouse cursor + */ + virtual void hideCursor() = 0; + + /** + * Set drawing bounds for a specified surface + */ + void setSurfaceBounds(SurfaceNum surfaceNum, const Rect &r); + + /** + * Set the current font number + */ + int setFontNumber(int fontNumber); +}; + +class OSScreenManager: CScreenManager { +private: + DirectDrawManager _directDrawManager; + + /** + * Frees any surface buffers + */ + void destroyFrontAndBackBuffers(); + + /** + * Load game cursors + */ + void loadCursors(); + + /** + * Gets an underlying surface + */ + DirectDrawSurface *getDDSurface(SurfaceNum surfaceNum); +public: + int _field48; + int _field4C; + int _field50; + int _field54; + STFont _fonts[4]; +public: + OSScreenManager(TitanicEngine *vm); + virtual ~OSScreenManager(); + + /** + * Sets the video mode + */ + virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2); + + /** + * Handles drawing the cursors + */ + virtual void drawCursors(); + + /** + * Locks a specified surface number for access and returns a pointer to it + */ + virtual CVideoSurface *lockSurface(SurfaceNum surfaceNum); + + /** + * Unlocks a previously locked surface + */ + virtual void unlockSurface(CVideoSurface *surface); + + /** + * Gets a specified surface number + */ + virtual CVideoSurface *getSurface(SurfaceNum surfaceNum) const; + + /** + * Return the front render surface + */ + virtual CVideoSurface *getFrontRenderSurface() const { + return _frontRenderSurface; + } + + + /** + * Fill an area with a specific color + */ + virtual void fillRect(SurfaceNum surfaceNum, Rect *rect, byte r, byte g, byte b); + + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, CVideoSurface *src, const Point *destPos, + const Rect *srcRect = nullptr); + + /** + * Blits a surface onto one of the screen surfaces + */ + virtual void blitFrom(SurfaceNum surfaceNum, const Rect *rect, CVideoSurface *src, int v = 0); + + /** + * Write a string + * @param surfaceNum Destination surface + * @param destRect Bounds within dest surface + * @param yOffset Y offset for drawing, to allow for parts of + * the text to be scrolled off-screen + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &destRect, + int yOffset, const CString &str, CTextCursor *textCursor); + + /** + * Write a string + * @param surfaceNum Destination surface + * @param srcRect Drawing area + * @param destRect Bounds of dest surface + * @param str Line or lines to write + * @param textCursor Optional text cursor pointer + */ + virtual int writeString(int surfaceNum, const Rect &srcRect, + const Rect &destRect, const CString &str, CTextCursor *textCursor); + + /** + * Set the font color + */ + virtual void setFontColor(byte r, byte g, byte b); + + /** + * Get the text area a string will fit into + * @param str String + * @param maxWidth Maximum width in pixels + * @param sizeOut Optional pointer to output size + * @returns Required height + */ + virtual int getTextBounds(const CString &str, int maxWidth, Point *sizeOut = nullptr) const; + + /** + * Get the current font height + */ + virtual int getFontHeight() const; + + /** + * Returns the width of a given string in pixels + */ + virtual int stringWidth(const CString &str); + + /** + * Draws a frame enclosing the specified area + */ + virtual void frameRect(SurfaceNum surfaceNum, const Rect &rect, byte r, byte g, byte b); + + /** + * Clear a portion of the screen surface + */ + virtual void clearSurface(SurfaceNum surfaceNum, Rect *bounds); + + /** + * Resize the passed surface + */ + virtual void resizeSurface(CVideoSurface *surface, int width, int height); + + /** + * Creates a surface of a given size + */ + virtual CVideoSurface *createSurface(int w, int h); + + /** + * Creates a surface from a specified resource + */ + virtual CVideoSurface *createSurface(const CResourceKey &key); + + /** + * Show the mouse cursor + */ + virtual void showCursor(); + + /** + * Hide the mouse cursor + */ + virtual void hideCursor(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SCREEN_MANAGER_H */ diff --git a/engines/titanic/support/simple_file.cpp b/engines/titanic/support/simple_file.cpp new file mode 100644 index 0000000000..35b2e28e4a --- /dev/null +++ b/engines/titanic/support/simple_file.cpp @@ -0,0 +1,512 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/util.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +CString readStringFromStream(Common::SeekableReadStream *s) { + CString result; + char c; + while ((c = s->readByte()) != '\0') + result += c; + + return result; +} + +/*------------------------------------------------------------------------*/ + +bool File::open(const Common::String &filename) { + if (!Common::File::open(filename)) + error("Could not open file - %s", filename.c_str()); + return true; +} + +/*------------------------------------------------------------------------*/ + +SimpleFile::SimpleFile(): _inStream(nullptr), _outStream(nullptr), _lineCount(1) { +} + +SimpleFile::~SimpleFile() { + close(); +} + +void SimpleFile::open(Common::SeekableReadStream *stream) { + close(); + _inStream = stream; +} + +void SimpleFile::open(Common::OutSaveFile *stream) { + close(); + _outStream = stream; +} + +void SimpleFile::close() { + if (_outStream) { + _outStream->finalize(); + delete _outStream; + _outStream = nullptr; + } + + if (_inStream) { + delete _inStream; + _inStream = nullptr; + } +} + +void SimpleFile::safeRead(void *dst, size_t count) { + if (unsafeRead(dst, count) != count) + error("Could not read %d bytes", (int)count); +} + +size_t SimpleFile::unsafeRead(void *dst, size_t count) { + assert(_inStream); + return _inStream->read(dst, count); +} + +size_t SimpleFile::write(const void *src, size_t count) const { + assert(_outStream); + return _outStream->write(src, count); +} + +void SimpleFile::seek(int offset, int origin) { + assert(_inStream); + _inStream->seek(offset, origin); +} + +byte SimpleFile::readByte() { + byte b; + safeRead(&b, 1); + return b; +} + +uint SimpleFile::readUint16LE() { + uint val; + safeRead(&val, 2); + return READ_LE_UINT16(&val); +} + +uint SimpleFile::readUint32LE() { + uint val; + safeRead(&val, 4); + return READ_LE_UINT32(&val); +} + +CString SimpleFile::readString() { + char c; + CString result; + bool backslashFlag = false; + + // First skip any spaces + do { + safeRead(&c, 1); + } while (Common::isSpace(c)); + + // Ensure we've found a starting quote for the string + if (c != '"') + error("Could not find starting quote"); + + bool endFlag = false; + while (!endFlag) { + // Read the next character + safeRead(&c, 1); + + if (backslashFlag) { + backslashFlag = false; + switch (c) { + case 'n': + result += '\n'; + break; + case 'r': + result += '\r'; + break; + case '\t': + result += '\t'; + break; + default: + result += c; + break; + } + } else { + switch (c) { + case '"': + endFlag = true; + break; + case '\\': + backslashFlag = true; + break; + default: + result += c; + break; + } + } + } + + // Return the string + return result; +} + +int SimpleFile::readNumber() { + char c; + int result = 0; + bool minusFlag = false; + + // First skip any spaces + do { + safeRead(&c, 1); + } while (Common::isSpace(c)); + + // Check for prefix sign + if (c == '+' || c == '-') { + minusFlag = c == '-'; + safeRead(&c, 1); + } + + // Read in the number + if (!Common::isDigit(c)) + error("Invalid number"); + + while (Common::isDigit(c)) { + result = result * 10 + (c - '0'); + safeRead(&c, 1); + } + + // Finally, if it's a minus value, then negate it + if (minusFlag) + result = -result; + + return result; +} + +double SimpleFile::readFloat() { + char c; + Common::String result; + + // First skip any spaces + do { + safeRead(&c, 1); + } while (Common::isSpace(c)); + + // Check for prefix sign + if (c == '+' || c == '-') { + result += c; + safeRead(&c, 1); + } + + // Read in the number + if (!Common::isDigit(c)) + error("Invalid number"); + + while (Common::isDigit(c) || c == '.') { + result += c; + safeRead(&c, 1); + } + + // Convert to a float and return it + float floatValue; + sscanf(result.c_str(), "%f", &floatValue); + + return floatValue; +} + +Point SimpleFile::readPoint() { + Point pt; + pt.x = readNumber(); + pt.y = readNumber(); + + return pt; +} + +Rect SimpleFile::readRect() { + Rect r; + r.left = readNumber(); + r.top = readNumber(); + r.right = readNumber(); + r.bottom = readNumber(); + + return r; +} + +Rect SimpleFile::readBounds() { + Rect r; + r.left = readNumber(); + r.top = readNumber(); + r.setWidth(readNumber()); + r.setHeight(readNumber()); + + return r; +} + +void SimpleFile::readBuffer(char *buffer, size_t count) { + CString tempString = readString(); + if (buffer) { + strncpy(buffer, tempString.c_str(), count); + buffer[count - 1] = '\0'; + } +} + +void SimpleFile::writeUint16LE(uint val) { + byte lo = val & 0xff; + byte hi = (val >> 8) & 0xff; + write(&lo, 1); + write(&hi, 1); +} + +void SimpleFile::writeUint32LE(uint val) { + uint16 lo = val & 0xffff; + uint16 hi = (val >> 16) & 0xff; + writeUint16LE(lo); + writeUint16LE(hi); +} + +void SimpleFile::writeLine(const CString &str) const { + write(str.c_str(), str.size()); + write("\r\n", 2); +} + +void SimpleFile::writeString(const CString &str) const { + if (str.empty()) + return; + + const char *msgP = str.c_str(); + char c; + + while ((c = *msgP++) != '\0') { + switch (c) { + case '\r': + write("\\r", 2); + break; + case '\n': + write("\\n", 2); + break; + case '\t': + write("\\t", 2); + break; + case '\"': + write("\\\"", 2); + break; + case '\\': + write("\\\\", 2); + break; + case '{': + write("\\{", 2); + break; + case '}': + write("\\}", 2); + break; + default: + write(&c, 1); + break; + } + } +} + +void SimpleFile::writeQuotedString(const CString &str) const { + write("\"", 1); + writeString(str); + write("\" ", 2); +} + +void SimpleFile::writeQuotedLine(const CString &str, int indent) const { + writeIndent(indent); + writeQuotedString(str); + write("\n", 1); +} + +void SimpleFile::writeNumber(int val) const { + CString str = CString::format("%d ", val); + write(str.c_str(), str.size()); +} + +void SimpleFile::writeNumberLine(int val, int indent) const { + writeIndent(indent); + writeNumber(val); + write("\n", 1); +} + +void SimpleFile::writeFloat(double val) const { + Common::String valStr = Common::String::format("%f ", val); + write(valStr.c_str(), valStr.size()); +} + +void SimpleFile::writeFloatLine(double val, int indent) const { + writeIndent(indent); + writeFloat(val); + write("\n", 1); +} + +void SimpleFile::writePoint(const Point &pt, int indent) const { + writeIndent(indent); + writeNumber(pt.x); + writeNumber(pt.y); + write("\n", 1); +} + +void SimpleFile::writeRect(const Rect &r, int indent) const { + writePoint(Point(r.left, r.top), indent); + writePoint(Point(r.right, r.bottom), indent); +} + +void SimpleFile::writeBounds(const Rect &r, int indent) const { + writePoint(Point(r.left, r.top), indent); + writePoint(Point(r.width(), r.height()), indent); +} + +void SimpleFile::writeFormat(const char *format, ...) const { + // Convert the format specifier and params to a string + va_list va; + va_start(va, format); + CString line = CString::vformat(format, va); + va_end(va); + + // Write out the string + write(format, strlen(format)); +} + +void SimpleFile::writeIndent(uint indent) const { + for (uint idx = 0; idx < indent; ++idx) + write("\t", 1); +} + +bool SimpleFile::IsClassStart() { + char c; + + do { + safeRead(&c, 1); + } while (Common::isSpace(c)); + + assert(c == '{' || c == '}'); + return c == '{'; +} + +void SimpleFile::writeClassStart(const CString &classStr, int indent) { + write("\n", 1); + writeIndent(indent); + write("{\n", 2); + writeIndent(indent + 1); + writeQuotedString(classStr); + write("\n", 1); +} + +void SimpleFile::writeClassEnd(int indent) { + writeIndent(indent); + write("}\n", 2); +} + +bool SimpleFile::scanf(const char *format, ...) { + va_list va; + va_start(va, format); + char c; + + CString formatStr(format); + while (!formatStr.empty()) { + if (formatStr.hasPrefix(" ")) { + formatStr.deleteChar(0); + + safeRead(&c, 1); + if (!Common::isSpace(c)) + return false; + + // Skip over whitespaces + skipSpaces(); + } else if (formatStr.hasPrefix("%d")) { + // Read in a number + formatStr = CString(formatStr.c_str() + 2); + int *param = (int *)va_arg(va, int *); + *param = readNumber(); + + if (!eos()) + _inStream->seek(-1, SEEK_CUR); + } else if (formatStr.hasPrefix("%s")) { + // Read in text until the next space + formatStr = CString(formatStr.c_str() + 2); + CString *str = (CString *)va_arg(va, CString *); + str->clear(); + while (!eos() && !Common::isSpace(c = readByte())) + *str += c; + + if (!eos()) + _inStream->seek(-1, SEEK_CUR); + } + } + + skipSpaces(); + va_end(va); + return true; +} + +void SimpleFile::skipSpaces() { + char c = ' '; + while (!eos() && Common::isSpace(c)) + safeRead(&c, 1); + + if (!eos()) + _inStream->seek(-1, SEEK_CUR); +} + +/*------------------------------------------------------------------------*/ + +bool StdCWadFile::open(const Common::String &filename) { + File f; + CString name = filename; + + // Check for whether it is indeed a file/resource pair + int idx = name.indexOf('#'); + + if (idx < 0) { + // Nope, so open up file for standard reading + assert(!name.empty()); + f.open(name); + + SimpleFile::open(f.readStream(f.size())); + return true; + } + + // Split up the name and resource, and get the resource index + CString fname = name.left(idx) + ".st"; + int extPos = name.lastIndexOf('.'); + CString resStr = name.mid(idx + 1, extPos - idx - 1); + int resIndex = resStr.readInt(); + + // Open up the index for access + f.open(fname); + int indexSize = f.readUint32LE() / 4; + assert(resIndex < indexSize); + + // Get the specific resource's offset, and size by also + // getting the offset of the following resource + f.seek(resIndex * 4); + uint resOffset = f.readUint32LE(); + uint nextOffset = (resIndex == (indexSize - 1)) ? f.size() : + f.readUint32LE(); + + // Read in the resource + f.seek(resOffset); + Common::SeekableReadStream *stream = f.readStream(nextOffset - resOffset); + SimpleFile::open(stream); + + f.close(); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/simple_file.h b/engines/titanic/support/simple_file.h new file mode 100644 index 0000000000..f5d0bc7c1b --- /dev/null +++ b/engines/titanic/support/simple_file.h @@ -0,0 +1,321 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SIMPLE_FILE_H +#define TITANIC_SIMPLE_FILE_H + +#include "common/file.h" +#include "titanic/support/rect.h" +#include "common/savefile.h" +#include "common/stream.h" +#include "common/zlib.h" +#include "titanic/support/string.h" + +namespace Titanic { + +class Decompressor; +class DecompressorData; + +/** + * Simple ScummVM File descendent that throws a wobbly if + * the file it tries to open isn't present + */ +class File : public Common::File { +public: + virtual bool open(const Common::String &filename); +}; + +/** + * This class implements basic reading and writing to files + */ +class SimpleFile { +private: + /** + * Skip over any pending spaces + */ + void skipSpaces(); +protected: + Common::SeekableReadStream *_inStream; + Common::OutSaveFile *_outStream; + int _lineCount; +public: + SimpleFile(); + virtual ~SimpleFile(); + + operator Common::SeekableReadStream &() { return *_inStream; } + operator Common::WriteStream &() { return *_outStream; } + + /** + * Set up a stream for read access + */ + virtual void open(Common::SeekableReadStream *stream); + + /** + * Set up a stream for write access + */ + virtual void open(Common::OutSaveFile *stream); + + /** + * Close the file + */ + virtual void close(); + + /** + * Read from the file with validation + */ + virtual void safeRead(void *dst, size_t count); + + /** + * Read from the file + */ + virtual size_t unsafeRead(void *dst, size_t count); + + /** + * Write out data + */ + virtual size_t write(const void *src, size_t count) const; + + /** + * Seek + */ + virtual void seek(int offset, int origin); + /** + * Read a byte + */ + byte readByte(); + + /** + * Read a 16-bit LE number + */ + uint readUint16LE(); + + /** + * Read a 32-bit LE number + */ + uint readUint32LE(); + + /** + * Read a string from the file + */ + CString readString(); + + /** + * Read a number from the file + */ + int readNumber(); + + /** + * Read a floating point number from the file + */ + double readFloat(); + + /** + * Read in a point + */ + Point readPoint(); + + /** + * Read in a rect + */ + Rect readRect(); + + /** + * Rect in a bounds + */ + Rect readBounds(); + + /** + * Read a string and copy it into an optionally passed buffer + */ + void readBuffer(char *buffer = nullptr, size_t count = 0); + + /** + * Scan in values from the file + */ + bool scanf(const char *format, ...); + + /** + * Write out a byte + */ + void writeByte(byte b) { write(&b, 1); } + + /** + * Write out a raw 16-bit LE number + */ + void writeUint16LE(uint val); + + /** + * Write out a raw 32-bit LE number + */ + void writeUint32LE(uint val); + + /** + * Write a string line + */ + void writeLine(const CString &str) const; + + /** + * Write a string + */ + void writeString(const CString &str) const; + + /** + * Write a quoted string + */ + void writeQuotedString(const CString &str) const; + + /** + * Write a quoted string line + */ + void writeQuotedLine(const CString &str, int indent) const; + + /** + * Write a number to file + */ + void writeNumber(int val) const; + + /** + * Write a number line to file + */ + void writeNumberLine(int val, int indent) const; + + /** + * Write a floating point number + */ + void writeFloat(double val) const; + + /** + * Write a floating point number as a line + */ + void writeFloatLine(double val, int indent) const; + + /** + * Write out a point line + */ + void writePoint(const Point &pt, int indent)const; + + /** + * Write out a rect line + */ + void writeRect(const Rect &r, int indent) const; + + /** + * Write out a bounds line + */ + void writeBounds(const Rect &r, int indent) const; + + /** + * Write out a string using a format specifier, just like fprintf + */ + void writeFormat(const char *format, ...) const; + + /** + * Write out a number of tabs to form an indent in the output + */ + void writeIndent(uint indent) const; + + /** + * Validates that the following non-space character is either + * an opening or closing squiggly bracket denoting a class + * definition start or end. Returns true if it's a class start + */ + bool IsClassStart(); + + /** + * Write the starting header for a class definition + */ + void writeClassStart(const CString &classStr, int indent); + + /** + * Write out the ending footer for a class definition + */ + void writeClassEnd(int indent); + + /** + * Return true if the stream has finished being read + */ + bool eos() const { + assert(_inStream); + return _inStream->pos() >= _inStream->size(); + } +}; + +/** + * Derived file that handles compressed files + */ +class CompressedFile : public SimpleFile { +public: + CompressedFile() : SimpleFile() {} + virtual ~CompressedFile() {} + + /** + * Set up a stream for read access + */ + virtual void open(Common::SeekableReadStream *stream) { + SimpleFile::open(Common::wrapCompressedReadStream(stream)); + } + + /** + * Set up a stream for write access + */ + virtual void open(Common::OutSaveFile *stream) { + SimpleFile::open(Common::wrapCompressedWriteStream(stream)); + } +}; + +/** + * Derived file that handles WAD archives containing multiple files + */ +class StdCWadFile : public SimpleFile { +public: + StdCWadFile() : SimpleFile() {} + virtual ~StdCWadFile() {} + + /** + * Open up the specified file + */ + virtual bool open(const Common::String &filename); + + /** + * Unsupported open method from parent class + */ + virtual void open(Common::SeekableReadStream *stream) {} + + /** + * Unsupported open method from parent class + */ + virtual void open(Common::OutSaveFile *stream) {} + + /** + * Return a reference to the read stream + */ + Common::SeekableReadStream *readStream() const { return _inStream; } +}; + +/** + * General purpose support method for reading an ASCIIZ string from a stream + */ +CString readStringFromStream(Common::SeekableReadStream *s); + +} // End of namespace Titanic + +#endif /* TITANIC_SIMPLE_FILE_H */ diff --git a/engines/titanic/support/string.cpp b/engines/titanic/support/string.cpp new file mode 100644 index 0000000000..cd39c03861 --- /dev/null +++ b/engines/titanic/support/string.cpp @@ -0,0 +1,125 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/algorithm.h" +#include "titanic/support/string.h" + +namespace Titanic { + +CString::CString(char c, uint32 len) : Common::String() { + ensureCapacity(len, false); + for (uint idx = 0; idx < len; ++idx) + (*this) += c; +} + +CString::CString(int val) : Common::String() { + *this = CString::format("%d", val); +} + +CString CString::left(uint count) const { + return (count > size()) ? CString() : CString(c_str(), c_str() + count); +} + +CString CString::right(uint count) const { + uint strSize = size(); + return (count > strSize) ? CString() : + CString(c_str() + strSize - count, c_str() + strSize); +} + +CString CString::mid(uint start, uint count) const { + if (start >= size()) + return CString(); + else + return CString(c_str() + start, MIN(count, size() - start)); +} + +CString CString::mid(uint start) const { + uint strSize = size(); + assert(start <= strSize); + return mid(start, strSize - start); +} + +int CString::indexOf(char c) const { + const char *charP = strchr(c_str(), c); + return charP ? charP - c_str() : -1; +} + +int CString::indexOf(const char *s) const { + const char *strP = strstr(c_str(), s); + return strP ? strP - c_str() : -1; +} + +int CString::lastIndexOf(char c) const { + const char *charP = strrchr(c_str(), c); + return charP ? charP - c_str() : -1; +} + +FileType CString::fileTypeSuffix() const { + CString ext = right(1); + if (ext == "0" || ext == "4") + return FILETYPE_IMAGE; + else if (ext == "1") + return FILETYPE_WAV; + else if (ext == "2" || ext == "3") + return FILETYPE_MOVIE; + + ext = right(3); + if (ext == "tga" || ext == "jpg") + return FILETYPE_IMAGE; + else if (ext == "wav") + return FILETYPE_WAV; + else if (ext == "avi" || ext == "mov") + return FILETYPE_MOVIE; + else if (ext == "dlg") + return FILETYPE_DLG; + else + return FILETYPE_UNKNOWN; +} + +ImageType CString::imageTypeSuffix() const { + CString ext = right(1); + if (ext == "0") + return IMAGETYPE_TARGA; + else if (ext == "4") + return IMAGETYPE_JPEG; + + ext = right(3); + if (ext == "tga") + return IMAGETYPE_TARGA; + else if (ext == "jpg") + return IMAGETYPE_JPEG; + else + return IMAGETYPE_UNKNOWN; +} + +CString CString::format(const char *fmt, ...) { + String output; + + va_list va; + va_start(va, fmt); + output = String::vformat(fmt, va); + va_end(va); + + return output; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/string.h b/engines/titanic/support/string.h new file mode 100644 index 0000000000..9550ce88a7 --- /dev/null +++ b/engines/titanic/support/string.h @@ -0,0 +1,114 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STRING_H +#define TITANIC_STRING_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "common/str.h" + +namespace Titanic { + +enum FileType { + FILETYPE_UNKNOWN = 0, FILETYPE_IMAGE = 1, FILETYPE_MOVIE = 2, + FILETYPE_WAV = 3, FILETYPE_DLG = 4 +}; + +enum ImageType { + IMAGETYPE_UNKNOWN = 0, IMAGETYPE_TARGA = 1, IMAGETYPE_JPEG = 2 +}; + +class CString : public Common::String { +public: + CString() : Common::String() {} + CString(const char *str) : Common::String(str) {} + CString(const char *str, uint32 len) : Common::String(str, len) {} + CString(const char *beginP, const char *endP) : Common::String(beginP, endP) {} + CString(const String &str) : Common::String(str) {} + CString(char c, uint32 len); + explicit CString(char c) : Common::String(c) {} + explicit CString(int val); + + /** + * Returns the left n characters of the string + */ + CString left(uint count) const; + + /** + * Returns the right n characters of the string + */ + CString right(uint count) const; + + /** + * Returns a substring from within the string + */ + CString mid(uint start, uint count) const; + + /** + * Returns a substring from within the string + */ + CString mid(uint start) const; + + /** + * Returns the index of the first occurance of a given character + */ + int indexOf(char c) const; + + /** + * Returns the index of the first occurance of a given string + */ + int indexOf(const char *s) const; + + /** + * Returns the index of the last occurance of a given character + */ + int lastIndexOf(char c) const; + + /** + * Returns the type of a filename based on it's extension + */ + FileType fileTypeSuffix() const; + + /** + * Returns the type of an image filename based on it's extension + */ + ImageType imageTypeSuffix() const; + + /** + * Parses the string as an integer and returns the value + */ + int readInt() const { + return atoi(c_str()); + } + + /** + * Format a string + */ + static CString format(const char *fmt, ...); +}; + +typedef Common::Array<CString> StringArray; + +} // End of namespace Titanic + +#endif /* TITANIC_STRING_H */ diff --git a/engines/titanic/support/text_cursor.cpp b/engines/titanic/support/text_cursor.cpp new file mode 100644 index 0000000000..ad3fe4ed26 --- /dev/null +++ b/engines/titanic/support/text_cursor.cpp @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/support/text_cursor.h" +#include "titanic/support/screen_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CTextCursor::CTextCursor(CScreenManager *screenManager) : + _screenManager(screenManager), _active(false), _blinkVisible(false), + _backRenderSurface(nullptr), _frontRenderSurface(nullptr), + _blinkDelay(300), _size(2, 10), _priorBlinkTime(0), + _cursorR(0), _cursorG(0), _cursorB(0), _mode(-1) { + _surface = screenManager->createSurface(10, 10); +} + +CTextCursor::~CTextCursor() { + delete _surface; +} + +void CTextCursor::setColor(byte r, byte g, byte b) { + _cursorR = r; + _cursorG = g; + _cursorB = b; +} + +void CTextCursor::show() { + _backRenderSurface = _screenManager->getSurface(SURFACE_BACKBUFFER); + _frontRenderSurface = _screenManager->getFrontRenderSurface(); + _active = true; + _priorBlinkTime = g_vm->_events->getTicksCount(); +} + +void CTextCursor::hide() { + _active = false; +} + +void CTextCursor::draw() { + if (!_active) + return; + + // Handle updating whether the blinking cursor is visible or not + uint newTicks = g_vm->_events->getTicksCount(); + while (newTicks > (_priorBlinkTime + _blinkDelay)) { + _priorBlinkTime += _blinkDelay; + _blinkVisible = !_blinkVisible; + } + + if (_blinkVisible) { + Rect cursorRect = getCursorBounds(); + _surface->blitFrom(Common::Point(0, 0), _backRenderSurface, &cursorRect); + + if (!_screenBounds.isEmpty()) + // Limit the cursor rect to only within designated screen area + cursorRect.constrain(_screenBounds); + + if (!cursorRect.isEmpty()) { + // Draw cursor onto the screen + _backRenderSurface->_ddSurface->fillRect(&cursorRect, + _cursorR, _cursorG, _cursorB); + } + + //_screenManager->blitFrom(SURFACE_BACKBUFFER, _surface, &_pos); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/text_cursor.h b/engines/titanic/support/text_cursor.h new file mode 100644 index 0000000000..d8c6ac0653 --- /dev/null +++ b/engines/titanic/support/text_cursor.h @@ -0,0 +1,121 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TEXT_CURSOR_H +#define TITANIC_TEXT_CURSOR_H + +#include "common/scummsys.h" +#include "titanic/support/rect.h" + +namespace Titanic { + +class CScreenManager; +class CVideoSurface; + +class CTextCursor { +private: + CScreenManager *_screenManager; + CVideoSurface *_backRenderSurface; + CVideoSurface *_frontRenderSurface; + Point _pos; + Rect _screenBounds; + uint _blinkDelay; + bool _blinkVisible; + Point _size; + Point _screenTopLeft; + uint _priorBlinkTime; + byte _cursorR; + byte _cursorG; + byte _cursorB; + CVideoSurface *_surface; + int _mode; +public: + bool _active; +public: + CTextCursor(CScreenManager *screenManager); + ~CTextCursor(); + + /** + * Sets the position of the cursor + */ + void setPos(const Point &pt) { _pos = pt; } + + /** + * Sets the size of the cursor + */ + void setSize(const Point &size) { _size = size; } + + /** + * Returns the bounds for the cursor + */ + Rect getCursorBounds() const { + return Rect(_pos.x, _pos.y, _pos.x + _size.x, _pos.y + _size.y); + } + + /** + * Set bounds + */ + void setBounds(const Rect &r) { _screenBounds = r; } + + /** + * Clear the bounds + */ + void clearBounds() { _screenBounds.clear(); } + + /** + * Set the blinking rate + */ + void setBlinkRate(uint ticks) { _blinkDelay = ticks; } + + /** + * Set the cursor color + */ + void setColor(byte r, byte g, byte b); + + /** + * Returns whether the text cursor is active + */ + bool isActive() const { return _active; } + + int getMode() const { return _mode; } + + void setMode(int mode) { _mode = mode; } + + /** + * Show the text cursor + */ + void show(); + + /** + * Hide the text cursor + */ + void hide(); + + /** + * Update and draw the cursor if necessary + */ + void draw(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TEXT_CURSOR_H */ diff --git a/engines/titanic/support/time_event_info.cpp b/engines/titanic/support/time_event_info.cpp new file mode 100644 index 0000000000..0226223f1a --- /dev/null +++ b/engines/titanic/support/time_event_info.cpp @@ -0,0 +1,206 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/time_event_info.h" +#include "titanic/core/game_object.h" +#include "titanic/core/project_item.h" +#include "titanic/messages/messages.h" + +namespace Titanic { + +void CTimeEventInfoList::postLoad(uint ticks, CProjectItem *project) { + for (iterator i = begin(); i != end(); ++i) + (*i)->postLoad(ticks, project); +} + +void CTimeEventInfoList::preSave(uint ticks) { + for (iterator i = begin(); i != end(); ++i) + (*i)->preSave(ticks); +} + +void CTimeEventInfoList::postSave() { + for (iterator i = begin(); i != end(); ++i) + (*i)->postSave(); +} + +void CTimeEventInfoList::update(uint ticks) { + // Remove any items that are done + for (iterator i = begin(); i != end(); ) { + CTimeEventInfo *item = *i; + if (item->_done) { + i = erase(i); + delete item; + } else { + ++i; + } + } + + // Handle updating the items + for (iterator i = begin(); i != end(); ) { + CTimeEventInfo *item = *i; + if (!item->update(ticks)) { + ++i; + } else { + i = erase(i); + delete item; + } + } +} + +void CTimeEventInfoList::stop(uint id) { + for (iterator i = begin(); i != end(); ++i) { + CTimeEventInfo *item = *i; + if (item->_id == id) { + item->_done = true; + return; + } + } +} + +void CTimeEventInfoList::setPersisent(uint id, bool flag) { + for (iterator i = begin(); i != end(); ++i) { + CTimeEventInfo *item = *i; + if (item->_id == id) { + item->setPersisent(flag); + return; + } + } +} + +/*------------------------------------------------------------------------*/ + +uint CTimeEventInfo::_nextId; + +CTimeEventInfo::CTimeEventInfo() : ListItem(), _lockCounter(0), + _repeated(false), _firstDuration(0), _repeatDuration(0), + _target(nullptr), _actionVal(0), _timerCtr(0), _done(false), + _lastTimerTicks(0), _relativeTicks(0), _persisent(true) { + _id = _nextId++; +} + +CTimeEventInfo::CTimeEventInfo(uint ticks, bool repeated, uint firstDuration, + uint repeatDuration, CTreeItem *target, int endVal, const CString &action) : + ListItem(), _lockCounter(0), _repeated(repeated), _firstDuration(firstDuration), + _repeatDuration(repeatDuration), _target(target), _actionVal(endVal), _done(false), + _timerCtr(0), _lastTimerTicks(ticks), _relativeTicks(0), _persisent(true) { + _id = _nextId++; +} + +void CTimeEventInfo::save(SimpleFile *file, int indent) { + file->writeNumberLine(0, indent); + + CString targetName; + if (_target) + targetName = _target->getName(); + file->writeQuotedLine(targetName, indent); + file->writeNumberLine(_id, indent); + file->writeNumberLine(_repeated, indent); + file->writeNumberLine(_firstDuration, indent); + file->writeNumberLine(_repeatDuration, indent); + file->writeNumberLine(_actionVal, indent); + file->writeQuotedLine(_action, indent); + file->writeNumberLine(_timerCtr, indent); + file->writeNumberLine(_relativeTicks, indent); + file->writeNumberLine(_done, indent); + file->writeNumberLine(_persisent, indent); +} + +void CTimeEventInfo::load(SimpleFile *file) { + lock(); + int val = file->readNumber(); + + if (!val) { + _targetName = file->readString(); + _id = file->readNumber(); + _repeated = file->readNumber(); + _firstDuration = file->readNumber(); + _repeatDuration = file->readNumber(); + _actionVal = file->readNumber(); + _action = file->readString(); + _timerCtr = file->readNumber(); + _relativeTicks = file->readNumber(); + _done = file->readNumber() != 0; + _persisent = file->readNumber() != 0; + _target = nullptr; + } +} + +void CTimeEventInfo::postLoad(uint ticks, CProjectItem *project) { + if (!_persisent || _targetName.empty()) + _done = true; + + // Get the timer's target + if (project) + _target = project->findByName(_targetName); + if (!_target) + _done = true; + + _lastTimerTicks = ticks + _relativeTicks; + if (_id >= _nextId) + _nextId = _id + 1; + + unlock(); +} + +void CTimeEventInfo::preSave(uint ticks) { + _relativeTicks = _lastTimerTicks - ticks; + lock(); +} + +void CTimeEventInfo::postSave() { + unlock(); +} + +bool CTimeEventInfo::update(uint ticks) { + if (_lockCounter) + return false; + + if (_timerCtr) { + if (ticks > (_lastTimerTicks + _repeatDuration)) { + ++_timerCtr; + _lastTimerTicks = ticks; + + if (_target) { + CTimerMsg timerMsg(ticks, _timerCtr, _actionVal, _action); + timerMsg.execute(_target); + } + } + } else { + if (ticks > (_lastTimerTicks + _firstDuration)) { + _timerCtr = 1; + _lastTimerTicks = ticks; + + if (_target) { + CTimerMsg timerMsg(ticks, _timerCtr, _actionVal, _action); + timerMsg.execute(_target); + } + + if (!_repeated) + // Event is done, and can be removed + return true; + } + } + + return false; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/time_event_info.h b/engines/titanic/support/time_event_info.h new file mode 100644 index 0000000000..ebf5b54458 --- /dev/null +++ b/engines/titanic/support/time_event_info.h @@ -0,0 +1,138 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TIMER_H +#define TITANIC_TIMER_H + +#include "common/algorithm.h" +#include "titanic/core/list.h" + +namespace Titanic { + +class CTreeItem; +class CProjectItem; + +class CTimeEventInfo : public ListItem { +private: + /** + * Increments the counter + */ + void lock() { ++_lockCounter; } + + /** + * Called at the end of both post load and post save actions + */ + void unlock() { + _lockCounter = MAX(_lockCounter - 1, 0); + } +public: + static uint _nextId; +public: + int _lockCounter; + uint _id; + bool _repeated; + uint _firstDuration; + uint _repeatDuration; + CTreeItem *_target; + uint _actionVal; + CString _action; + uint _timerCtr; + uint _lastTimerTicks; + uint _relativeTicks; + bool _done; + bool _persisent; + CString _targetName; +public: + CLASSDEF; + CTimeEventInfo(); + CTimeEventInfo(uint ticks, bool repeated, uint firstDuration, uint repeatDuration, + CTreeItem *target, int endVal, const CString &action); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); + + /** + * Called after loading a game has finished + */ + void postLoad(uint ticks, CProjectItem *project); + + /** + * Called when a game is about to be saved + */ + void preSave(uint ticks); + + /** + * Called when a game has finished being saved + */ + void postSave(); + + bool update(uint ticks); + + /** + * Flags whether the timer will be persisent across save & loads + */ + void setPersisent(bool val) { _persisent = val; } +}; + +class CTimeEventInfoList : public List<CTimeEventInfo> { +public: + /** + * Called after loading a game has finished + */ + void postLoad(uint ticks, CProjectItem *project); + + /** + * Called when a game is about to be saved + */ + void preSave(uint ticks); + + /** + * Called when a game has finished being saved + */ + void postSave(); + + /** + * Handles an update + */ + void update(uint ticks); + + /** + * Remove an item with the given Id + */ + void stop(uint id); + + /** + * Sets whether a timer with a given Id will be persisent across saves + */ + void setPersisent(uint id, bool flag); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TIMER_H */ diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp new file mode 100644 index 0000000000..594f660937 --- /dev/null +++ b/engines/titanic/support/video_surface.cpp @@ -0,0 +1,583 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/support/video_surface.h" +#include "titanic/support/image_decoders.h" +#include "titanic/support/screen_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +int CVideoSurface::_videoSurfaceCounter = 0; + +CVideoSurface::CVideoSurface(CScreenManager *screenManager) : + _screenManager(screenManager), _rawSurface(nullptr), _movie(nullptr), + _pendingLoad(false), _transBlitFlag(false), _fastBlitFlag(false), + _movieFrameSurface(nullptr), _transparencyMode(TRANS_DEFAULT), + _freeMovieSurface(DisposeAfterUse::NO), _hasFrame(true), _lockCount(0) { + _videoSurfaceNum = _videoSurfaceCounter++; +} + +CVideoSurface::~CVideoSurface() { + if (_ddSurface) + _videoSurfaceCounter -= freeSurface(); + --_videoSurfaceCounter; + + if (_freeMovieSurface == DisposeAfterUse::YES) + delete _movieFrameSurface; +} + +void CVideoSurface::setSurface(CScreenManager *screenManager, DirectDrawSurface *surface) { + _screenManager = screenManager; + _ddSurface = surface; +} + +void CVideoSurface::blitFrom(const Point &destPos, CVideoSurface *src, const Rect *srcRect) { + if (loadIfReady() && src->loadIfReady() && _ddSurface && src->_ddSurface) { + Rect srcBounds, destBounds; + clipBounds(srcBounds, destBounds, src, srcRect, &destPos); + + if (src->_transBlitFlag) + blitRect2(srcBounds, destBounds, src); + else + blitRect1(srcBounds, destBounds, src); + } +} + +void CVideoSurface::blitFrom(const Point &destPos, const Graphics::Surface *src) { + lock(); + _rawSurface->blitFrom(*src, destPos); + unlock(); +} + +void CVideoSurface::clipBounds(Rect &srcRect, Rect &destRect, + CVideoSurface *srcSurface, const Rect *subRect, const Point *destPos) { + // Figure out initial source rect and dest rect, based on whether + // specific subRect and/or destPos have been passed + if (destPos) { + destRect.left = destPos->x; + destRect.top = destPos->y; + } else { + destRect.left = destRect.top = 0; + } + + if (subRect) { + destRect.right = destRect.left + subRect->width(); + destRect.bottom = destRect.top + subRect->height(); + srcRect = *subRect; + } else { + srcRect.right = srcRect.left + srcSurface->getWidth(); + srcRect.bottom = srcRect.top + srcSurface->getHeight(); + srcRect = Rect(0, 0, srcSurface->getWidth(), srcSurface->getHeight()); + } + + // Clip destination rect to be on-screen + if (destRect.left < 0) { + srcRect.left -= destRect.left; + destRect.left = 0; + } + if (destRect.top < 0) { + srcRect.top -= destRect.top; + destRect.top = 0; + } + if (destRect.right > getWidth()) { + srcRect.right += getWidth() - destRect.right; + destRect.right = getWidth(); + } + if (destRect.bottom > getHeight()) { + srcRect.bottom += getHeight() - destRect.bottom; + destRect.bottom = getHeight(); + } + + // Clip source rect to be within the source surface + if (srcRect.left < 0) { + destRect.left -= srcRect.left; + srcRect.left = 0; + } + if (srcRect.top < 0) { + destRect.top -= srcRect.top; + srcRect.top = 0; + } + if (srcRect.right > srcSurface->getWidth()) { + destRect.right += srcSurface->getWidth() - srcRect.right; + srcRect.right = srcSurface->getWidth(); + } + if (srcRect.bottom > srcSurface->getHeight()) { + destRect.bottom += srcSurface->getHeight() - srcRect.bottom; + srcRect.bottom = srcSurface->getHeight(); + } + + // Validate that the resulting rects are valid + if (destRect.left >= destRect.right || destRect.top >= destRect.bottom + || srcRect.left >= srcRect.right || srcRect.top >= srcRect.bottom) + error("Invalid rect"); +} + +void CVideoSurface::blitRect1(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) { + src->lock(); + lock(); + + if (src->_fastBlitFlag) { + _rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top)); + } else if (getMovieFrameSurface()) { + movieBlitRect(srcRect, destRect, src); + } else { + _rawSurface->transBlitFrom(*src->_rawSurface, srcRect, destRect, src->getTransparencyColor()); + } + + src->unlock(); + unlock(); +} + +void CVideoSurface::blitRect2(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) { + if (getMovieFrameSurface()) { + movieBlitRect(srcRect, destRect, src); + } else { + src->lock(); + lock(); + + _rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top)); + + src->unlock(); + unlock(); + } +} + +void CVideoSurface::movieBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src) { + // TODO +} + +uint CVideoSurface::getTransparencyColor() { + uint32 val = -(getPixelDepth() - 2); + val &= 0xFFFF8400; + val += 0xF81F; + return val; +} + +bool CVideoSurface::hasFrame() { + if (_hasFrame) { + _hasFrame = false; + return true; + } else if (_movie) { + return _movie->hasVideoFrame(); + } else { + return false; + } +} + +/*------------------------------------------------------------------------*/ + +byte OSVideoSurface::_palette1[32][32]; +byte OSVideoSurface::_palette2[32][32]; + +OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface) : + CVideoSurface(screenManager) { + _ddSurface = surface; +} + +OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool pendingLoad) : + CVideoSurface(screenManager) { + _ddSurface = nullptr; + _pendingLoad = pendingLoad; + + if (_pendingLoad) { + loadResource(key); + } else { + _resourceKey = key; + load(); + } +} + +void OSVideoSurface::setupPalette(byte palette[32][32], byte val) { + for (uint idx1 = 0; idx1 < 32; ++idx1) { + for (uint idx2 = 0, base = 0; idx2 < 32; ++idx2, base += idx1) { + int64 v = 0x84210843; + v *= base; + uint v2 = (v >> 36); + v = ((v2 >> 31) + v2) & 0xff; + palette[idx1][idx2] = v << 3; + + if (val != 0xff && v != idx2) { + v = 0x80808081 * v * val; + v2 = v >> 39; + palette[idx1][idx2] = ((v2 >> 31) + v2) << 3; + } + } + } +} + +void OSVideoSurface::loadResource(const CResourceKey &key) { + _resourceKey = key; + _pendingLoad = true; + + if (hasSurface()) + load(); +} + +void OSVideoSurface::loadTarga(const CResourceKey &key) { + // Decode the image + CTargaDecode decoder; + decoder.decode(*this, key.getString()); + + if (getPixelDepth() == 2) + shiftColors(); + + _resourceKey = key; + +} + +void OSVideoSurface::loadJPEG(const CResourceKey &key) { + // Decode the image + CJPEGDecode decoder; + decoder.decode(*this, key.getString()); + + if (getPixelDepth() == 2) + shiftColors(); + + _resourceKey = key; +} + +void OSVideoSurface::loadTarga(const CString &name) { + CResourceKey key(name); + loadTarga(key); +} + +void OSVideoSurface::loadMovie(const CResourceKey &key, bool destroyFlag) { + // Delete any prior movie + if (_movie) { + delete _movie; + _movie = nullptr; + } + + // Create the new movie and load the first frame to the video surface + _movie = g_vm->_movieManager.createMovie(key, this); + _movie->setFrame(0); + + // If flagged to destroy, then immediately destroy movie instance + if (destroyFlag) { + delete _movie; + _movie = nullptr; + } + + _resourceKey = key; +} + +bool OSVideoSurface::lock() { + if (!loadIfReady()) + return false; + + ++_lockCount; + _rawSurface = _ddSurface->lock(nullptr, 0); + return true; +} + +void OSVideoSurface::unlock() { + if (!--_lockCount) { + if (_rawSurface) + _ddSurface->unlock(); + _rawSurface = nullptr; + } +} + +bool OSVideoSurface::hasSurface() { + return _ddSurface != nullptr; +} + +int OSVideoSurface::getWidth() { + if (!loadIfReady()) + error("Could not load resource"); + + return _ddSurface->getWidth(); +} + +int OSVideoSurface::getHeight() { + if (!loadIfReady()) + error("Could not load resource"); + + return _ddSurface->getHeight(); +} + +int OSVideoSurface::getPitch() { + if (!loadIfReady()) + error("Could not load resource"); + + return _ddSurface->getPitch(); +} + +int OSVideoSurface::getBpp() { + if (!loadIfReady()) + error("Could not load resource"); + + return getPixelDepth(); +} + +void OSVideoSurface::recreate(int width, int height) { + freeSurface(); + + _screenManager->resizeSurface(this, width, height); + if (_ddSurface) + _videoSurfaceCounter += _ddSurface->getSize(); +} + +void OSVideoSurface::resize(int width, int height) { + if (!_ddSurface || _ddSurface->getWidth() != width || + _ddSurface->getHeight() != height) + recreate(width, height); +} + +void OSVideoSurface::detachSurface() { + _ddSurface = nullptr; +} + +int OSVideoSurface::getPixelDepth() { + if (!loadIfReady()) + error("Could not load resource"); + + lock(); + + int result = _rawSurface->format.bytesPerPixel; + if (result == 1) + // Paletted 8-bit images don't store the color directly in the pixels + result = 0; + + unlock(); + return result; +} + +bool OSVideoSurface::load() { + if (!_resourceKey.scanForFile()) + return false; + + switch (_resourceKey.fileTypeSuffix()) { + case FILETYPE_IMAGE: + switch (_resourceKey.imageTypeSuffix()) { + case IMAGETYPE_TARGA: + loadTarga(_resourceKey); + break; + case IMAGETYPE_JPEG: + loadJPEG(_resourceKey); + break; + default: + break; + } + return true; + + case FILETYPE_MOVIE: + loadMovie(_resourceKey); + return true; + + default: + return false; + } +} + +uint16 OSVideoSurface::getPixel(const Common::Point &pt) { + if (!loadIfReady()) + return 0; + + if (pt.x >= 0 && pt.y >= 0 && pt.x < getWidth() && pt.y < getHeight()) { + lock(); + uint16 pixel = *(uint16 *)_rawSurface->getBasePtr(pt.x, pt.y); + unlock(); + return pixel; + } else { + return getTransparencyColor(); + } +} + +void OSVideoSurface::setPixel(const Point &pt, uint pixel) { + assert(getPixelDepth() == 2); + + uint16 *pixelP = (uint16 *)_rawSurface->getBasePtr(pt.x, pt.y); + *pixelP = pixel; +} + +void OSVideoSurface::changePixel(uint16 *pixelP, uint16 *color, byte srcVal, bool remapFlag) { + assert(getPixelDepth() == 2); + const Graphics::PixelFormat &destFormat = _ddSurface->getFormat(); + const Graphics::PixelFormat srcFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + + // Get the color + byte r, g, b; + srcFormat.colorToRGB(*color, r, g, b); + if (remapFlag) { + r = _palette1[31 - srcVal][r >> 3]; + g = _palette1[31 - srcVal][g >> 3]; + b = _palette1[31 - srcVal][b >> 3]; + } + + byte r2, g2, b2; + destFormat.colorToRGB(*pixelP, r2, g2, b2); + r2 = _palette1[srcVal][r2 >> 3]; + g2 = _palette1[srcVal][g2 >> 3]; + b2 = _palette1[srcVal][b2 >> 3]; + + *pixelP = destFormat.RGBToColor(r + r2, g + g2, b + b2); +} + +void OSVideoSurface::shiftColors() { + if (!loadIfReady()) + return; + + // Currently no further processing is needed, since for ScummVM, + // we already convert 16-bit surfaces as soon as they're loaded +} + +void OSVideoSurface::clear() { + if (!loadIfReady()) + error("Could not load resource"); + +} + +void OSVideoSurface::playMovie(uint flags, CGameObject *obj) { + if (loadIfReady() && _movie) + _movie->play(flags, obj); + + _ddSurface->fill(nullptr, 0); +} + +void OSVideoSurface::playMovie(uint startFrame, uint endFrame, uint flags, CGameObject *obj) { + if (loadIfReady() && _movie) { + _movie->play(startFrame, endFrame, flags, obj); + } +} + +void OSVideoSurface::playMovie(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj) { + if (loadIfReady() && _movie) { + _movie->play(startFrame, endFrame, initialFrame, flags, obj); + } +} + +void OSVideoSurface::stopMovie() { + if (_movie) + _movie->stop(); +} + +void OSVideoSurface::setMovieFrame(uint frameNumber) { + if (loadIfReady() && _movie) + _movie->setFrame(frameNumber); +} + +void OSVideoSurface::addMovieEvent(int frameNumber, CGameObject *obj) { + if (_movie) + _movie->addEvent(frameNumber, obj); +} + +void OSVideoSurface::setMovieFrameRate(double rate) { + if (_movie) + _movie->setFrameRate(rate); +} + +const CMovieRangeInfoList *OSVideoSurface::getMovieRangeInfo() const { + return _movie ? _movie->getMovieRangeInfo() : nullptr; +} + +void OSVideoSurface::flipVertically(bool needsLock) { + if (!loadIfReady() || !_transBlitFlag) + return; + + if (needsLock) + lock(); + + byte lineBuffer[SCREEN_WIDTH * 2]; + int pitch = getBpp() * getWidth(); + assert(pitch < (SCREEN_WIDTH * 2)); + + for (int yp = 0; yp < (_rawSurface->h / 2); ++yp) { + byte *line1P = (byte *)_rawSurface->getBasePtr(0, yp); + byte *line2P = (byte *)_rawSurface->getBasePtr(0, _rawSurface->h - yp - 1); + + Common::copy(line1P, line1P + pitch, lineBuffer); + Common::copy(line2P, line2P + pitch, line1P); + Common::copy(lineBuffer, lineBuffer + pitch, line1P); + } + + _transBlitFlag = false; + if (needsLock) + unlock(); +} + +bool OSVideoSurface::loadIfReady() { + _videoSurfaceNum = _videoSurfaceCounter; + + if (hasSurface()) { + return true; + } else if (_pendingLoad) { + _hasFrame = true; + load(); + return true; + } else { + return false; + } +} + +void OSVideoSurface::transPixelate() { + if (!loadIfReady()) + return; + + lock(); + Graphics::ManagedSurface *surface = _rawSurface; + uint transColor = getTransparencyColor(); + // TODO: Check whether color is correct + uint pixelColor = surface->format.RGBToColor(0x50, 0, 0); + + for (int yp = 0; yp < surface->h; ++yp) { + uint16 *pixelsP = (uint16 *)surface->getBasePtr(0, yp); + bool bitFlag = (yp % 2) == 0; + int replaceCtr = yp & 3; + + for (int xp = 0; xp < surface->w; ++xp, ++pixelsP) { + if (bitFlag && *pixelsP == transColor && replaceCtr == 0) + *pixelsP = pixelColor; + + bitFlag = !bitFlag; + replaceCtr = (replaceCtr + 1) & 3; + } + } + + surface->markAllDirty(); + unlock(); +} + +Graphics::ManagedSurface *OSVideoSurface::dupMovieFrame() const { + return _movie ? _movie->duplicateFrame() : nullptr; +} + +int OSVideoSurface::freeSurface() { + if (!_ddSurface) + return 0; + int surfaceSize = _ddSurface->getSize(); + + delete _movie; + _movie = nullptr; + delete _ddSurface; + _ddSurface = nullptr; + + return surfaceSize; +} + +uint16 *OSVideoSurface::getBasePtr(int x, int y) { + assert(_rawSurface); + return (uint16 *)_rawSurface->getBasePtr(x, y); +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h new file mode 100644 index 0000000000..053eabb0f9 --- /dev/null +++ b/engines/titanic/support/video_surface.h @@ -0,0 +1,537 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_VIDEO_SURFACE_H +#define TITANIC_VIDEO_SURFACE_H + +#include "common/scummsys.h" +#include "common/array.h" +#include "graphics/managed_surface.h" +#include "titanic/support/font.h" +#include "titanic/support/direct_draw.h" +#include "titanic/support/movie.h" +#include "titanic/support/movie_range_info.h" +#include "titanic/support/rect.h" +#include "titanic/core/list.h" +#include "titanic/core/resource_key.h" + +namespace Titanic { + +enum TransparencyMode { + TRANS_MASK0 = 0, TRANS_MASK255 = 1, TRANS_ALPHA0 = 2, + TRANS_ALPHA255 = 3, TRANS_DEFAULT = 4 +}; + +class CScreenManager; +class CJPEGDecode; +class CTargaDecode; + +class CVideoSurface : public ListItem { + friend class CJPEGDecode; + friend class CTargaDecode; +private: + /** + * Calculates blitting bounds + */ + void clipBounds(Rect &srcRect, Rect &destRect, CVideoSurface *srcSurface, + const Rect *subRect = nullptr, const Point *destPos = nullptr); + + void blitRect1(const Rect &srcRect, const Rect &destRect, CVideoSurface *src); + void blitRect2(const Rect &srcRect, const Rect &destRect, CVideoSurface *src); + void movieBlitRect(const Rect &srcRect, const Rect &destRect, CVideoSurface *src); +protected: + static int _videoSurfaceCounter; +protected: + CScreenManager *_screenManager; + Graphics::ManagedSurface *_rawSurface; + bool _pendingLoad; + Graphics::ManagedSurface *_movieFrameSurface; + DisposeAfterUse::Flag _freeMovieSurface; + int _videoSurfaceNum; + bool _hasFrame; + int _lockCount; +public: + CMovie *_movie; + DirectDrawSurface *_ddSurface; + bool _fastBlitFlag; + bool _transBlitFlag; + CResourceKey _resourceKey; + TransparencyMode _transparencyMode; +public: + CVideoSurface(CScreenManager *screenManager); + virtual ~CVideoSurface(); + + /** + * Set the underlying surface for this video surface + */ + void setSurface(CScreenManager *screenManager, DirectDrawSurface *surface); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file) { + ListItem::load(file); + } + + /** + * Load the surface with the passed resource + */ + virtual void loadResource(const CResourceKey &key) = 0; + + /** + * Loads a Targa image file specified by the resource key + */ + virtual void loadTarga(const CResourceKey &key) = 0; + + /** + * Loads a JPEG image file specified by the resource key + */ + virtual void loadJPEG(const CResourceKey &key) = 0; + + /** + * Loads a Targa image file specified by the given name + */ + virtual void loadTarga(const CString &name) = 0; + + /** + * Loads a movie file specified by the resource key. + * @param key Resource key for movie to load + * @param destroyFlag Immediately destroy movie after decoding first frame + */ + virtual void loadMovie(const CResourceKey &key, bool destroyFlag = false) = 0; + + /** + * Lock the surface for direct access to the pixels + */ + virtual bool lock() = 0; + + /** + * Unlocks the surface after prior calls to lock() + */ + virtual void unlock() = 0; + + /** + * Returns true if an underlying raw surface has been set + */ + virtual bool hasSurface() = 0; + + /** + * Returns the width of the surface + */ + virtual int getWidth() = 0; + + /** + * Returns the height of the surface + */ + virtual int getHeight() = 0; + + /** + * Returns the pitch of the surface in bytes + */ + virtual int getPitch() = 0; + + /** + * Returns the bytes per pixel of the surface + */ + virtual int getBpp() = 0; + + /** + * Recreates the surface + */ + virtual void recreate(int width, int height) = 0; + + /** + * Resizes the surface + */ + virtual void resize(int width, int height) = 0; + + /** + * Detachs the underlying raw surface + */ + virtual void detachSurface() = 0; + + /** + * Returns the number of bytes per pixel in the surface + */ + virtual int getPixelDepth() = 0; + + /** + * Gets the pixel at the specified position within the surface + */ + virtual uint16 getPixel(const Common::Point &pt) = 0; + + + /** + * Sets a pixel at a specified position within the surface + */ + virtual void setPixel(const Point &pt, uint pixel) = 0; + + /** + * Change a pixel + */ + virtual void changePixel(uint16 *pixelP, uint16 *color, byte srcVal, bool remapFlag = true) = 0; + + /** + * Shifts the colors of the surface.. maybe greys it out? + */ + virtual void shiftColors() = 0; + + /** + * Clears the entire surface to black + */ + virtual void clear() = 0; + + /** + * Plays a movie, loading it from the specified _resource + * if not already loaded + */ + virtual void playMovie(uint flags, CGameObject *obj) = 0; + + /** + * Plays a movie, loading it from the specified _resource + * if not already loaded + */ + virtual void playMovie(uint startFrame, uint endFrame, uint flags, CGameObject *obj) = 0; + + /** + * Plays a movie, loading it from the specified _resource + * if not already loaded + */ + virtual void playMovie(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj) = 0; + + /** + * Stops any movie currently attached to the surface + */ + virtual void stopMovie() = 0; + + /** + * Set the current movie frame number + */ + virtual void setMovieFrame(uint frameNumber) = 0; + + /** + * Adds a movie playback event + */ + virtual void addMovieEvent(int eventId, CGameObject *obj) = 0; + + /** + * Set the movie frame rate + */ + virtual void setMovieFrameRate(double rate) = 0; + + /** + * Return any movie range info associated with the surface's movie + */ + virtual const CMovieRangeInfoList *getMovieRangeInfo() const = 0; + + /** + * + */ + virtual void flipVertically(bool needsLock = true) = 0; + + /** + * Loads the surface's resource if there's one pending + */ + virtual bool loadIfReady() = 0; + + /** + * Loads the surface data based on the currently set resource key + */ + virtual bool load() = 0; + + /** + * Does a replacement of transparent pixels on certain lines at regular + * intervals. This is totally weird + */ + virtual void transPixelate() = 0; + + /** + * Returns true if there's a frame to display on the video surface + */ + virtual bool hasFrame(); + + /** + * Duplicates movie frame surface + */ + virtual Graphics::ManagedSurface *dupMovieFrame() const = 0; + + /** + * Frees the underlying surface + */ + virtual int freeSurface() { return 0; } + + /** + * Get a pointer into the underlying surface + */ + virtual uint16 *getBasePtr(int x, int y) = 0; + + /** + * Blit from another surface + */ + void blitFrom(const Point &destPos, CVideoSurface *src, const Rect *srcRect = nullptr); + + /** + * Blit from another surface + */ + void blitFrom(const Point &destPos, const Graphics::Surface *src); + + /** + * Sets the movie frame surface containing frame data from an active movie + */ + void setMovieFrameSurface(Graphics::ManagedSurface *frameSurface) { _movieFrameSurface = frameSurface; } + + /** + * Get the previously set movie frame surface + */ + Graphics::ManagedSurface *getMovieFrameSurface() const { return _movieFrameSurface; } + + /** + * Get the pixels associated with the surface. Only valid when the + * surface has been locked for access + */ + uint16 *getPixels() { return (uint16 *)_rawSurface->getPixels(); } + + /** + * Get a reference to the underlying surface. Only valid when the surface + * has been locked for access + */ + Graphics::ManagedSurface *getRawSurface() { return _rawSurface; } + + /** + * Returns the transparent color + */ + uint getTransparencyColor(); +}; + +class OSVideoSurface : public CVideoSurface { + friend class OSMovie; +private: + static byte _palette1[32][32]; + static byte _palette2[32][32]; + + /** + * Setup the shading palettes + */ + static void setupPalette(byte palette[32][32], byte val); +public: + /** + * Setup statics + */ + static void setup() { + setupPalette(_palette1, 0xff); + setupPalette(_palette2, 0xe0); + } +public: + OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface); + OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool flag = false); + + /** + * Load the surface with the passed resource + */ + virtual void loadResource(const CResourceKey &key); + + /** + * Loads a Targa image file specified by the resource key + */ + virtual void loadTarga(const CResourceKey &key); + + /** + * Loads a JPEG image file specified by the resource key + */ + virtual void loadJPEG(const CResourceKey &key); + + /** + * Loads a Targa image file specified by the given name + */ + virtual void loadTarga(const CString &name); + + /** + * Loads a movie file specified by the resource key. + * @param key Resource key for movie to load + * @param destroyFlag Immediately destroy movie after decoding first frame + */ + virtual void loadMovie(const CResourceKey &key, bool destroyFlag = false); + + /** + * Lock the surface for direct access to the pixels + */ + virtual bool lock(); + + /** + * Unlocks the surface after prior calls to lock() + */ + virtual void unlock(); + + /** + * Returns true if an underlying raw surface has been set + */ + virtual bool hasSurface(); + + /** + * Returns the width of the surface + */ + virtual int getWidth(); + + /** + * Returns the height of the surface + */ + virtual int getHeight(); + + /** + * Returns the pitch of the surface in bytes + */ + virtual int getPitch(); + + /** + * Returns the bytes per pixel of the surface + */ + virtual int getBpp(); + + /** + * Recreates the surface with the designated size + */ + virtual void recreate(int width, int height); + + /** + * Resizes the surface + */ + virtual void resize(int width, int height); + + /** + * Detachs the underlying raw surface + */ + virtual void detachSurface(); + + /** + * Returns the number of bytes per pixel in the surface + */ + virtual int getPixelDepth(); + + /** + * Gets the pixel at the specified position within the surface + */ + virtual uint16 getPixel(const Point &pt); + + /** + * Sets a pixel at a specified position within the surface + */ + virtual void setPixel(const Point &pt, uint pixel); + + /** + * Change a pixel + */ + virtual void changePixel(uint16 *pixelP, uint16 *color, byte srcVal, bool remapFlag = true); + + /** + * Shifts the colors of the surface.. maybe greys it out? + */ + virtual void shiftColors(); + + /** + * Clears the entire surface to black + */ + virtual void clear(); + + /** + * Plays a movie, loading it from the specified _resource + * if not already loaded + */ + virtual void playMovie(uint flags, CGameObject *obj); + + /** + * Plays a movie, loading it from the specified _resource + * if not already loaded + */ + virtual void playMovie(uint startFrame, uint endFrame, uint flags, CGameObject *obj); + + /** + * Plays a movie, loading it from the specified _resource + * if not already loaded + */ + virtual void playMovie(uint startFrame, uint endFrame, uint initialFrame, uint flags, CGameObject *obj); + + /** + * Stops any movie currently attached to the surface + */ + virtual void stopMovie(); + + /** + * Sets the movie to the specified frame number + */ + virtual void setMovieFrame(uint frameNumber); + + /** + * Adds a movie playback event + */ + virtual void addMovieEvent(int frameNumber, CGameObject *obj); + + /** + * Set the movie frame rate + */ + virtual void setMovieFrameRate(double rate); + + /** + * Return any movie range info associated with the surface's movie + */ + virtual const CMovieRangeInfoList *getMovieRangeInfo() const; + + /** + * + */ + virtual void flipVertically(bool needsLock = true); + + /** + * Loads the surface's resource if there's one pending + */ + virtual bool loadIfReady(); + + /** + * Loads the surface data based on the currently set resource key + */ + virtual bool load(); + + /** + * Does a replacement of transparent pixels on certain lines at regular + * intervals. This is totally weird + */ + virtual void transPixelate(); + + /** + * Duplicates movie frame surface + */ + virtual Graphics::ManagedSurface *dupMovieFrame() const; + + + /** + * Frees the underlying surface + */ + virtual int freeSurface(); + + /** + * Get a pointer into the underlying surface + */ + virtual uint16 *getBasePtr(int x, int y); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_VIDEO_SURFACE_H */ diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp new file mode 100644 index 0000000000..af894d6997 --- /dev/null +++ b/engines/titanic/titanic.cpp @@ -0,0 +1,216 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" +#include "common/archive.h" +#include "common/config-manager.h" +#include "common/debug-channels.h" +#include "common/events.h" +#include "engines/util.h" +#include "graphics/scaler.h" +#include "graphics/thumbnail.h" +#include "titanic/titanic.h" +#include "titanic/debugger.h" +#include "titanic/carry/hose.h" +#include "titanic/core/saveable_object.h" +#include "titanic/game/get_lift_eye2.h" +#include "titanic/game/television.h" +#include "titanic/game/parrot/parrot_lobby_object.h" +#include "titanic/game/sgt/sgt_navigation.h" +#include "titanic/game/sgt/sgt_state_room.h" +#include "titanic/moves/enter_exit_first_class_state.h" +#include "titanic/moves/enter_exit_sec_class_mini_lift.h" +#include "titanic/moves/exit_pellerator.h" +#include "titanic/support/simple_file.h" +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +TitanicEngine *g_vm; + +TitanicEngine::TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDesc) + : _gameDescription(gameDesc), Engine(syst), _randomSource("Titanic") { + g_vm = this; + _debugger = nullptr; + _events = nullptr; + _filesManager = nullptr; + _window = nullptr; + _screen = nullptr; + _screenManager = nullptr; + _scriptHandler = nullptr; + _script = nullptr; + CMusicRoom::_musicHandler = nullptr; +} + +TitanicEngine::~TitanicEngine() { + delete _debugger; + delete _events; + delete _screen; + delete _window; + delete _screenManager; + delete _filesManager; + CSaveableObject::freeClassList(); +} + +void TitanicEngine::initializePath(const Common::FSNode &gamePath) { + Engine::initializePath(gamePath); + SearchMan.addSubDirectoryMatching(gamePath, "assets"); +} + +void TitanicEngine::initialize() { + // Set up debug channels + DebugMan.addDebugChannel(kDebugCore, "core", "Core engine debug level"); + DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts"); + DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling"); + DebugMan.addDebugChannel(kDebugSound, "sound", "Sound and Music handling"); + + _debugger = new Debugger(this); + _filesManager = new CFilesManager(); + + CSaveableObject::initClassList(); + CEnterExitFirstClassState::init(); + CGameObject::init(); + CGetLiftEye2::init(); + CHose::init(); + CMovie::init(); + CParrotLobbyObject::init(); + CSGTNavigation::init(); + CSGTStateRoom::init(); + CExitPellerator::init(); + CEnterExitSecClassMiniLift::init(); + CTelevision::init(); + TTnpcScript::init(); + OSVideoSurface::setup(); + + _events = new Events(this); + _screen = new Graphics::Screen(0, 0); + _screenManager = new OSScreenManager(this); + _window = new CMainGameWindow(this); + + setItemNames(); + setRoomNames(); + + _window->applicationStarting(); +} + +void TitanicEngine::deinitialize() { + CEnterExitFirstClassState::deinit(); + CGetLiftEye2::deinit(); + CHose::deinit(); + CMovie::deinit(); + CSGTNavigation::deinit(); + CSGTStateRoom::deinit(); + CExitPellerator::deinit(); + CEnterExitSecClassMiniLift::deinit(); + CGameObject::deinit(); + CTelevision::deinit(); + TTnpcScript::deinit(); +} + +Common::Error TitanicEngine::run() { + initialize(); + + // Main event loop + while (!shouldQuit()) { + _events->pollEventsAndWait(); + } + + deinitialize(); + return Common::kNoError; +} + +void TitanicEngine::setItemNames() { + Common::SeekableReadStream *r; + r = g_vm->_filesManager->getResource("TEXT/ITEM_NAMES"); + while (r->pos() < r->size()) + _itemNames.push_back(readStringFromStream(r)); + delete r; + + r = g_vm->_filesManager->getResource("TEXT/ITEM_DESCRIPTIONS"); + while (r->pos() < r->size()) + _itemNames.push_back(readStringFromStream(r)); + delete r; + + r = g_vm->_filesManager->getResource("TEXT/ITEM_IDS"); + while (r->pos() < r->size()) + _itemIds.push_back(readStringFromStream(r)); + delete r; +} + +void TitanicEngine::setRoomNames() { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/ROOM_NAMES"); + while (r->pos() < r->size()) + _roomNames.push_back(readStringFromStream(r)); + delete r; +} + + +bool TitanicEngine::canLoadGameStateCurrently() { + return _window->_inputAllowed; +} + +bool TitanicEngine::canSaveGameStateCurrently() { + return _window->_inputAllowed; +} + +Common::Error TitanicEngine::loadGameState(int slot) { + _window->_project->loadGame(slot); + return Common::kNoError; +} + +Common::Error TitanicEngine::saveGameState(int slot, const Common::String &desc) { + _window->_project->saveGame(slot, desc); + return Common::kNoError; +} + +CString TitanicEngine::generateSaveName(int slot) { + return CString::format("%s.%03d", _targetName.c_str(), slot); +} + +CString TitanicEngine::getSavegameName(int slot) { + // Try and open up the savegame for access + Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading( + generateSaveName(slot)); + + if (in) { + // Read in the savegame header data + CompressedFile file; + file.open(in); + + TitanicSavegameHeader header; + bool isValid = CProjectItem::readSavegameHeader(&file, header); + if (header._thumbnail) { + header._thumbnail->free(); + delete header._thumbnail; + } + + file.close(); + + if (isValid) + // Set the name text + return header._saveName; + } + + return CString(); +} + +} // End of namespace Titanic diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h new file mode 100644 index 0000000000..3c71f68b6e --- /dev/null +++ b/engines/titanic/titanic.h @@ -0,0 +1,183 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TITANIC_H +#define TITANIC_TITANIC_H + +#include "common/scummsys.h" +#include "common/random.h" +#include "common/str-array.h" +#include "common/system.h" +#include "common/serializer.h" +#include "engines/advancedDetector.h" +#include "engines/engine.h" +#include "graphics/screen.h" +#include "titanic/debugger.h" +#include "titanic/events.h" +#include "titanic/support/files_manager.h" +#include "titanic/main_game_window.h" +#include "titanic/support/exe_resources.h" +#include "titanic/support/movie_manager.h" +#include "titanic/support/screen_manager.h" +#include "titanic/support/string.h" +#include "titanic/true_talk/tt_script_base.h" + +/** + * This is the namespace of the Titanic engine. + * + * Status of this engine: In Development + * + * Games using this engine: + * - Starship Titanic + */ +namespace Titanic { + +enum TitanicDebugChannels { + kDebugCore = 1 << 0, + kDebugScripts = 1 << 1, + kDebugGraphics = 1 << 2, + kDebugSound = 1 << 3 +}; + +enum Season { + SPRING = 0, + SUMMER = 1, + AUTUMN = 2, + WINTER = 3 +}; + +#define TITANIC_SAVEGAME_VERSION 1 + +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 + +#define ERROR_BASIC 1 +#define ERROR_INTERMEDIATE 2 +#define ERROR_DETAILED 3 + +#define TOTAL_ITEMS 46 +#define TOTAL_ROOMS 34 + +#define MAX_SAVES 99 + +struct TitanicGameDescription; +class TitanicEngine; + +class TitanicEngine : public Engine { +private: + /** + * Handles basic initialization + */ + void initialize(); + + /** + * Handles game deinitialization + */ + void deinitialize(); + + /** + * Sets up the item names, short, and long descriptions + */ + void setItemNames(); + + /** + * Sets up the list of room names + */ + void setRoomNames(); +protected: + const TitanicGameDescription *_gameDescription; + int _loadSaveSlot; + + // Engine APIs + virtual void initializePath(const Common::FSNode &gamePath); + virtual Common::Error run(); + virtual bool hasFeature(EngineFeature f) const; +public: + Debugger *_debugger; + Events *_events; + CFilesManager *_filesManager; + CMovieManager _movieManager; + Graphics::Screen *_screen; + OSScreenManager *_screenManager; + CMainGameWindow *_window; + Common::RandomSource _randomSource; + CScriptHandler *_scriptHandler; + TTscriptBase *_script; + CTrueTalkManager *_trueTalkManager; + CExeResources _exeResources; + StringArray _itemNames; + StringArray _itemDescriptions; + CString _itemObjects[TOTAL_ITEMS]; + StringArray _itemIds; + StringArray _roomNames; +public: + TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDesc); + virtual ~TitanicEngine(); + + + /** + * Returns true if a savegame can be loaded + */ + virtual bool canLoadGameStateCurrently(); + + /** + * Returns true if the game can be saved + */ + virtual bool canSaveGameStateCurrently(); + + /** + * Called by the GMM to load a savegame + */ + virtual Common::Error loadGameState(int slot); + + /** + * Called by the GMM to save the game + */ + virtual Common::Error saveGameState(int slot, const Common::String &desc); + + uint32 getFeatures() const; + bool isDemo() const; + Common::Language getLanguage() const; + + /** + * Gets a random number + */ + uint getRandomNumber(uint max) { return _randomSource.getRandomNumber(max); } + + /** + * Support method that generates a savegame name + * @param slot Slot number + */ + CString generateSaveName(int slot); + + /** + * Checks whether a savegame exists for the given slot, + * and if it exists, returns it's description + */ + CString getSavegameName(int slot); +}; + +extern TitanicEngine *g_vm; + +} // End of namespace Titanic + +#endif /* TITANIC_TITANIC_H */ diff --git a/engines/titanic/true_talk/barbot_script.cpp b/engines/titanic/true_talk/barbot_script.cpp new file mode 100644 index 0000000000..b327c3647e --- /dev/null +++ b/engines/titanic/true_talk/barbot_script.cpp @@ -0,0 +1,1200 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/barbot_script.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +static const int STATE_ARRAY[7] = { + 0xCAB0, 0xCAB2, 0xCAB3, 0xCAB4, 0xCAB5, 0xCAB6, 0xCAB7 +}; + +static const uint ARRAY1[] = { + 0, 50033, 50044, 50045, 50046, 50047, 50048, 50049, + 50050, 50051, 50034, 50035, 50036, 50037, 50038, 50039, + 50040, 50041, 50042, 50043, 50411, 0 +}; + +static const uint ARRAY2[] = { + 51899, 51900, 51901, 51902, 51903, 51904, 51905, 51906, 51907, 0 +}; + +BarbotScript::BarbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) { + _state = 0; + _arrIndex = 0; + + loadRanges("Ranges/Barbot"); + loadResponses("Responses/Barbot"); + setupSentences(); + _tagMappings.load("TagMap/Barbot"); + _quotes.load("Quotes/Barbot"); + _states.load("States/Barbot"); + _preResponses.load("PreResponses/Barbot"); +} + +void BarbotScript::setupSentences() { + for (int idx = 28; idx < 35; ++idx) + CTrueTalkManager::setFlags(idx, 0); + setupDials(100, 100, 100); + + if (!_currentDialNum) + _currentDialNum = 2; + + _mappings.load("Mappings/Barbot", 8); + _entries.load("Sentences/Barbot"); + _entries2.load("Sentences/Barbot2"); + _words.load("Words/Barbot"); +} + +int BarbotScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) { + if (tag == MKTAG('D', 'N', 'A', '1') || tag == MKTAG('H', 'H', 'G', 'Q') || + tag == MKTAG('A', 'N', 'S', 'W') || tag == MKTAG('S', 'U', 'M', 'S')) { + if (_state < 7) { + addResponse(STATE_ARRAY[_state++]); + } else { + selectResponse(51896); + setState(1); + _state = 0; + } + + applyResponse(); + return 2; + + } else if (tag == MKTAG('S', 'W', 'E', 'R')) { + adjustDial(0, -18); + adjustDial(1, -5); + + if (getRandomNumber(100) > 50) { + addResponse(getDialogueId(getDialRegion(0) == 0 ? 250200 : 250062)); + applyResponse(); + return 2; + } + + } else if (tag == MKTAG('B', 'A', 'R', 'K') && getRandomNumber(100) > 50) { + selectResponse(250025); + switch (getDialsBitset()) { + case 4: + case 6: + addResponse(getDialogueId(250125)); + break; + default: + break; + } + + applyResponse(); + return 2; + + } else if (tag == MKTAG('B', 'A', 'R', 'U') && getRandomNumber(100) > 50) { + selectResponse(250025); + switch (getDialsBitset()) { + case 4: + case 6: + addResponse(getDialogueId(250112)); + break; + default: + break; + } + + applyResponse(); + return 2; + } + + if (tag == MKTAG('T', 'H', 'R', 'T') || tag == MKTAG('S', 'L', 'O', 'W') || + tag == MKTAG('S', 'E', 'X', '1') || tag == MKTAG('P', 'K', 'U', 'P')) { + adjustDial(0, -7); + adjustDial(1, -3); + } + + return TTnpcScript::chooseResponse(roomScript, sentence, tag); +} + +int BarbotScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + int dialogueId = 0; + + if (roomScript->_scriptId != 112) + return 2; + + checkItems(roomScript, sentence); + if (isState9()) { + if (sentence->localWord("visioncenter") || sentence->localWord("brain") || + sentence->contains("vision") || sentence->contains("visual") || + sentence->contains("brain") || sentence->contains("crystal")) { + if (CTrueTalkManager::getStateValue(2)) { + addResponse(getDialogueId(251003)); + applyResponse(); + CTrueTalkManager::triggerAction(6, 0); + return 2; + } + } + + if (sentence->contains("goldfish")) { + addResponse(getDialogueId(250184)); + applyResponse(); + return 2; + } + + dialogueId = ARRAY1[getRandomNumber(20)]; + if (!ARRAY2[_arrIndex]) + _arrIndex = 0; + + if (_arrIndex) { + dialogueId = ARRAY2[_arrIndex++]; + } else if (getRandomNumber(100) > 35) { + dialogueId = ARRAY2[0]; + _arrIndex = 1; + } else if (getRandomNumber(100) > 60) { + switch (sentence->_field2C) { + case 2: + dialogueId = 51914; + break; + case 3: + dialogueId = 51911; + break; + case 4: + dialogueId = 51913; + break; + case 5: + dialogueId = 51912; + break; + case 6: + dialogueId = 51915; + break; + case 7: + dialogueId = 51909; + break; + default: + break; + } + } + + addResponse(dialogueId); + if (getRandomNumber(100) > 65) + addResponse(getDialogueId(251250)); + applyResponse(); + return 2; + } + + CTrueTalkManager::setFlags(29, getValue(29) - 1); + CTrueTalkManager::setFlags(30, getValue(30) - 1); + CTrueTalkManager::setFlags(31, getValue(31) - 1); + CTrueTalkManager::setFlags(32, getValue(32) - 1); + CTrueTalkManager::setFlags(33, getValue(33) - 1); + CTrueTalkManager::setFlags(34, getValue(34) - 1); + + TTtreeResult treeResult; + int val34 = getState(); + setState(0); + + int val2C = sentence->_field2C; + bool flag = val2C == 11 || val2C == 13; + bool flag2 = val2C == 12; + + if (!val34) { + goto done; + } else if (val34 > 50357) { + goto done; + } else if (val34 == 50357) { + return applySentenceIds(50358, -1); + } + + switch (val34) { + case 1: + if (flag) + return applySentenceIds(51898, 2); + if (flag2) + return applySentenceIds(51897); + break; + case 2: + if (flag) + return applySentenceIds(51897); + break; + case 3: + if (sentence->localWord("useless") || sentence->contains("useless")) + return applySentenceIds(50824); + break; + case 4: + if (flag) + return applySentenceIds(getRandomBit() ? 50512 : 51642); + else if (flag2) + return applySentenceIds(getRandomBit() ? 50511 : 51643); + break; + case 5: + if (flag) + return applySentenceIds(50829, 6); + if (flag2) + return applySentenceIds(50828); + break; + case 6: + if (flag) + return applySentenceIds(50831); + if (flag2) + return applySentenceIds(50830); + break; + case 7: + if (flag2 || sentence->contains("never")) + return applySentenceIds(51553); + if (flag || sentence->contains("nicest")) + return applySentenceIds(51554); + break; + case 8: + if (flag) + return applySentenceIds(50961); + if (flag2) + return applySentenceIds(50960); + break; + case 9: + if (flag) + return applySentenceIds(getDialogueId(251858)); + break; + case 10: + if (flag) + return applySentenceIds(getDialogueId(251014)); + else if (flag2) + return applySentenceIds(getDialogueId(251013)); + break; + case 11: + if (flag) + return applySentenceIds(getDialogueId(251008)); + else if (flag2) + return applySentenceIds(getDialogueId(251007)); + break; + case 12: + if (flag) + return applySentenceIds(getDialogueId(250656)); + else if (flag2) + return applySentenceIds(getDialogueId(250655)); + break; + case 13: + if (flag) + return applySentenceIds(getDialogueId(250614)); + else if (flag2) + return applySentenceIds(getDialogueId(250613)); + break; + case 14: + if (val2C == 6) + return applySentenceIds(getDialogueId(250946)); + break; + case 15: + if (flag || sentence->contains("or")) { + return applySentenceIds(getDialogueId(250526), 16); + } else { + if (g_vm->_trueTalkManager->_quotesTree.search( + sentence->_normalizedLine.c_str(), TREE_3, &treeResult, 0, nullptr) != -1) { + uint newId = getDialogueId(250526); + return applySentenceIds(newId, 16); + } + } + break; + case 17: + if (flag) { + return applySentenceIds(50382); + } else if (flag2) { + return applySentenceIds(51423); + } + // Deliberate fall-through + + case 16: + if (val2C == 7 || val2C == 10) + return applySentenceIds(getDialogueId(250525)); + break; + case 18: + return applySentenceIds(getDialogueId(250589)); + case 19: + return applySentenceIds(getDialogueId(250565), 20); + case 20: + if (flag) + return applySentenceIds(50307); + if (flag2) + return applySentenceIds(50306); + break; + case 21: + if (flag) + return applySentenceIds(50359); + if (flag2) + return applySentenceIds(50357); + break; + case 23: + if (val2C == 6 || val2C == 10) + return applySentenceIds(getDialogueId(250551)); + break; + case 24: + if (sentence->contains("do not know") + || sentence->contains("no idea") + || sentence->contains("a clue")) { + return applySentenceIds(getDialogueId(250553)); + } else { + return applySentenceIds(getDialogueId(250552)); + } + break; + case 25: + if (flag || val2C == 10) + applySentenceIds(getDialogueId(251899), 26); + else if (flag2) + return applySentenceIds(50215); + break; + case 26: + if (g_vm->_trueTalkManager->_quotesTree.search( + sentence->_normalizedLine.c_str(), TREE_3, &treeResult, 0, nullptr) != -1) + return applySentenceIds(getDialogueId(251899), 26); + break; + + case 27: + if (flag) + return applySentenceIds(getDialogueId(250766)); + else if (flag2) + return applySentenceIds(getDialogueId(250764)); + break; + case 28: + return applySentenceIds(getDialogueId(250765)); + case 29: + return applySentenceIds(getDialogueId(250652)); + case 30: + return applySentenceIds(getDialogueId(250653)); + case 31: + if (flag) + return applySentenceIds(getDialogueId(250664)); + else if (flag2) + return applySentenceIds(getDialogueId(250663)); + break; + case 32: + if (flag) + return applySentenceIds(getDialogueId(250643)); + else if (flag2) + return applySentenceIds(getDialogueId(250642)); + break; + case 33: + return applySentenceIds(50763); + case 34: + if (flag) + return applySentenceIds(getDialogueId(251622)); + else if (flag2) + return applySentenceIds(getDialogueId(251624)); + break; + case 35: + if (val2C == 6 || val2C == 10) + return applySentenceIds(getDialogueId(251623)); + break; + case 36: + if (flag) + return applySentenceIds(50335); + if (flag2) + return applySentenceIds(50334); + break; + case 37: + if (flag) + return applySentenceIds(50217); + if (flag2) + return applySentenceIds(50153); + break; + case 38: + return applySentenceIds(getDialogueId(250637)); + case 39: + return applySentenceIds(getDialogueId(250638)); + case 40: + return applySentenceIds(getDialogueId(250639)); + case 41: + return applySentenceIds(getDialogueId(250640)); + case 42: + if (flag) + return applySentenceIds(getDialogueId(250676)); + else if (flag2) + return applySentenceIds(getDialogueId(250673)); + break; + case 43: + if (flag) + return applySentenceIds(50416, -1); + if (flag2) + return applySentenceIds(50415, -1); + break; + case 44: + if (flag) + return applySentenceIds(getDialogueId(250468)); + else if (flag2) + return applySentenceIds(getDialogueId(250413)); + + if (val2C == 6 || val2C == 10) + return applySentenceIds(getDialogueId(251649)); + break; + case 45: + if (sentence->localWord("summer") + || sentence->contains("summer") + || sentence->localWord("autumn") + || sentence->contains("autumn")) { + return applySentenceIds(50743); + } else if (sentence->localWord("winter") || sentence->contains("winter")) { + return applySentenceIds(50696); + } else { + return applySentenceIds(50225); + } + break; + case 46: + if (val2C == 7 || val2C == 10) + return applySentenceIds(50698); + break; + case 47: + if (flag || flag2 || val2C == 6) + return applySentenceIds(50717); + break; + case 48: + if (flag) + return applySentenceIds(50710); + if (flag2) + return applySentenceIds(50225); + break; + case 49: + if (sentence->localWord("scraliontis") || sentence->contains("scraliontis")) + return applySentenceIds(50711); + if (sentence->localWord("brobostigon") || sentence->contains("brobostigon")) + return applySentenceIds(50712); + break; + case 50: + return applySentenceIds(50713); + case 51: + if (flag) + return applySentenceIds(50715); + if (flag2) + return applySentenceIds(50714); + break; + case 52: + if (sentence->localWord("note") || sentence->contains("note")) + return applySentenceIds(50716); + return applySentenceIds(50210); + case 53: + return applySentenceIds(50210); + case 54: + if (getDialRegion(0) != 0) { + if (val2C == 12) + return applySentenceIds(50174); + else + return applySentenceIds(50300); + } else if (val2C == 7 || val2C == 10) { + return applySentenceIds(50871); + } + break; + case 55: + if (flag) + return applySentenceIds(50302); + if (flag2) + return applySentenceIds(50301); + break; + case 56: + if (flag) + return applySentenceIds(50304); + if (flag2) + return applySentenceIds(50303); + break; + case 57: + if (sentence->localWord("mustard") + || sentence->contains("mustard") + || sentence->localWord("tomato") + || sentence->contains("tomato")) + return applySentenceIds(50320); + if (sentence->localWord("sauce") + || sentence->localWord("puree") + || sentence->contains("sauce") + || sentence->contains("puree") + || sentence->contains("bird") + || sentence->contains("starling")) { + applySentenceIds(50321); + CTrueTalkManager::triggerAction(30, 0); + return 2; + } + + return applySentenceIds(50320); + case 58: + if (val2C == 6 || val2C == 10) + return applySentenceIds(50880); + break; + case 59: + if (flag) { + if (addRandomResponse(true)) { + setState(59); + return 2; + } + } else if (flag2) { + return applySentenceIds(getDialogueId(251754)); + } + break; + case 60: + if (flag && addRandomResponse(true)) { + setState(59); + return 2; + } else if (flag2 || val2C == 7 || val2C == 10) { + return applySentenceIds(getDialogueId(251712)); + } + break; + case 61: + if (val2C == 3) { + if (sentence->localWord("loop")) + return applySentenceIds(getDialogueId(250269)); + else if (sentence->localWord("do")) + return applySentenceIds(getDialogueId(250270)); + } else if (val2C == 7) { + return applySentenceIds(getDialogueId(250270)); + } else if (flag) { + return applySentenceIds(getDialogueId(250270)); + } + + return applySentenceIds(getDialogueId(250272)); + case 62: + if (flag + || (val2C == 3 && sentence->localWord("do")) + || val2C == 7 + || sentence->localWord("help")) + return applySentenceIds(getDialogueId(250270)); + + return applySentenceIds(getDialogueId(2570272)); + case 63: + if (flag + || (val2C == 3 || sentence->localWord("do")) + || val2C == 7 + || sentence->localWord("help")) + return applySentenceIds(getDialogueId(250271)); + + return applySentenceIds(getDialogueId(250272)); + case 64: + if (flag || val2C == 3 || val2C == 8) + return applySentenceIds(getDialogueId(250631)); + break; + case 65: + if (sentence->localWord("now") || sentence->localWord("soonh")) + return applySentenceIds(getDialogueId(250424)); + return applySentenceIds(getDialogueId(250506)); + case 66: + if (flag || sentence->localWord("good") || sentence->localWord("well")) + return applySentenceIds(getDialogueId(251027)); + return applySentenceIds(getDialogueId(251021)); + case 67: + if (flag || val2C == 6 || val2C == 10) { + setDial(0, getDialLevel(0, false) - 8); + return applySentenceIds(getDialogueId(251589)); + } + break; + case 68: + if (flag || val2C == 6 || val2C == 10) { + setDial(0, getDialLevel(0, false) - 12); + return applySentenceIds(getDialogueId(251590)); + } + break; + case 69: + if (flag || val2C == 6 || val2C == 10) { + setDial(0, getDialLevel(0, false) - 25); + return applySentenceIds(getDialogueId(251591)); + } + break; + default: + break; + } + +done: + // Adjust primary dial + setState(0); + if (sentence->get58() != 5) { + adjustDial(0, sentence->get58() * 4 - 20); + } else if (getDialLevel(0, false) > 65) { + adjustDial(0, -2 - getRandomNumber(7)); + } else if (getDialLevel(0, false) < 35) { + adjustDial(0, 2 + getRandomNumber(7)); + } + + updateCurrentDial(true); + + if (sentence->contains("goldfish")) { + addResponse(250184); + } else if ((sentence->localWord("puree") || sentence->localWord("pureed")) + && sentence->localWord("parrot")) { + addResponse(250021); + } else if (sentence->localWord("starling")) { + addResponse(250024); + } else { + if (getRandomNumber(100) > 95 && getDialRegion(2) == 0) { + addResponse(getDialogueId(250210)); + } + + if (processEntries(&_entries, _entryCount, roomScript, sentence) == 2) + return 2; + if (processEntries(_defaultEntries, 0, roomScript, sentence) != 2 + && !defaultProcess(roomScript, sentence)) { + int dval = 0; + flag = getRandomNumber(100) > 50; + int val; + + switch (_field2C) { + case 2: + val = getValue(29); + if (val < 16) + val += 4; + if (val < 9) { + val = val / 2; + dval = 250081 + (flag ? 0 : 267); + } + CTrueTalkManager::setFlags(29, val); + break; + + case 3: + val = getValue(30); + if (val < 16) + val += 4; + if (val < 9) { + val = val / 2; + dval = 250081 + (flag ? 0 : 243); + } + CTrueTalkManager::setFlags(30, val); + break; + + case 4: + val = getValue(31); + if (val < 16) + val += 4; + if (val < 9) { + val = val / 2; + dval = 250081 + (flag ? 0 : 256); + } + CTrueTalkManager::setFlags(31, val); + break; + + case 5: + val = getValue(32); + if (val < 16) + val += 4; + if (val < 9) { + val = val / 2; + dval = 250081 + (flag ? 0 : 251); + } + CTrueTalkManager::setFlags(32, val); + break; + + case 6: + val = getValue(33); + if (val < 16) + val += 4; + if (val < 9) { + val = val / 2; + dval = 250081 + (flag ? 0 : 273); + } + CTrueTalkManager::setFlags(33, val); + break; + + case 7: + val = getValue(34); + if (val < 16) + val += 4; + if (val < 9) { + val = val / 2; + dval = 250081 + (flag ? 0 : 236); + } + CTrueTalkManager::setFlags(34, val); + break; + + + case 11: + addResponse(getDialogueId(250463)); + applyResponse(); + return 2; + + case 12: + addResponse(getDialogueId(250455)); + applyResponse(); + return 2; + + case 13: + addResponse(getDialogueId(250447)); + applyResponse(); + return 2; + + case 19: + return applySentenceIds(getDialogueId(getDialRegion(0) ? 250062 : 250200)); + + default: + break; + } + + if (dval) { + adjustDial(0, -9); + adjustDial(1, -2); + + if (dval != 250081) { + selectResponse(250286); + selectResponse(250296); + selectResponse(250307); + applyResponse(); + return 2; + } + } else if (processEntries(&_entries2, 0, roomScript, sentence) == 2) { + return 2; + } + + addResponse(getDialogueId(250082 + getRandomNumber(100) <= 89 ? 128 : 0)); + } + } + + applyResponse(); + return 2; +} + +ScriptChangedResult BarbotScript::scriptChanged(const TTroomScript *roomScript, uint id) { + switch (id) { + case 1: + case 100: + if (!isState9()) { + selectResponse(250210); + applyResponse(); + } + + adjustDial(0, getRandomBit() ? getRandomNumber(5) * 4 : + -(int)getRandomNumber(5) * 4); + break; + + case 3: + if (isState9()) { + selectResponse(250244); + applyResponse(); + resetFlags(); + } else { + if (!getValue(28) || !fn10(true)) { + addResponse(getDialogueId(251627 + getValue(28) ? -1034 : 0)); + applyResponse(); + } + + CTrueTalkManager::setFlags(28, 1); + resetFlags(); + } + break; + + case 4: + selectResponse(isState9() ? 250141 : 250140); + applyResponse(); + adjustDial(2, getDialLevel(2, false) < 50 ? -15 - getRandomNumber(30) : + 15 + getRandomNumber(30)); + + if (getDialRegion(1) != 0 && getRandomNumber(100) > 75) + adjustDial(1, -35); + break; + + case 143: + addResponse(getDialogueId(isState9() ? 250577 : 250576)); + break; + + case 144: + addResponse(getDialogueId(isState9() ? 250577 : 250584)); + break; + + case 145: + if (isState9()) { + addResponse(getDialogueId(250577)); + applyResponse(); + } else { + setState(57); + } + break; + + case 146: + addResponse(getDialogueId(isState9() ? 250577 : 250574)); + break; + + case 147: + addResponse(getDialogueId(250579)); + break; + + } + + if (id >= 250000 && id <= 251900) { + if (id > 250571) { + if (id != 250575 && (id == 250586 || id == 251858 || !isState9())) { + addResponse(getDialogueId(id)); + applyResponse(); + } + } else if (id == 250571 || (id != 250244 && !isState9()) || isState9()) { + addResponse(getDialogueId(id)); + applyResponse(); + } else { + addResponse(getDialogueId(251018)); + applyResponse(); + } + } + + return SCR_2; +} + +int BarbotScript::handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder) { + switch (tagId) { + case MKTAG('A', 'D', 'V', 'T'): + case MKTAG('A', 'R', 'T', 'I'): + case MKTAG('A', 'R', 'T', 'Y'): + case MKTAG('B', 'R', 'N', 'D'): + case MKTAG('C', 'O', 'M', 'D'): + case MKTAG('D', 'N', 'C', 'E'): + case MKTAG('H', 'B', 'B', 'Y'): + case MKTAG('M', 'A', 'G', 'S'): + case MKTAG('L', 'I', 'T', 'R'): + case MKTAG('M', 'C', 'P', 'Y'): + case MKTAG('M', 'I', 'N', 'S'): + case MKTAG('M', 'U', 'S', 'I'): + case MKTAG('N', 'I', 'K', 'E'): + case MKTAG('S', 'F', 'S', 'F'): + case MKTAG('S', 'O', 'A', 'P'): + case MKTAG('S', 'O', 'N', 'G'): + case MKTAG('S', 'P', 'R', 'T'): + case MKTAG('T', 'E', 'A', 'M'): + case MKTAG('T', 'U', 'S', 'H'): + case MKTAG('W', 'W', 'E', 'B'): + tagId = MKTAG('E', 'N', 'T', 'N'); + break; + case MKTAG('A', 'U', 'T', 'H'): + case MKTAG('B', 'A', 'R', 'K'): + case MKTAG('B', 'L', 'R', '1'): + case MKTAG('B', 'L', 'P', '1'): + case MKTAG('B', 'L', 'P', '2'): + case MKTAG('B', 'L', 'P', '3'): + case MKTAG('B', 'L', 'P', '4'): + case MKTAG('B', 'L', 'T', '1'): + case MKTAG('B', 'L', 'T', '2'): + case MKTAG('B', 'L', 'T', '3'): + case MKTAG('B', 'L', 'T', '4'): + case MKTAG('B', 'L', 'T', '5'): + case MKTAG('B', 'O', 'Y', 'S'): + case MKTAG('C', 'O', 'P', 'S'): + case MKTAG('D', 'C', 'T', 'R'): + case MKTAG('F', 'A', 'M', 'E'): + case MKTAG('F', 'A', 'S', 'H'): + case MKTAG('G', 'I', 'R', 'L'): + case MKTAG('H', 'E', 'R', 'O'): + case MKTAG('H', 'O', 'S', 'T'): + case MKTAG('K', 'N', 'O', 'B'): + case MKTAG('N', 'H', 'R', 'O'): + case MKTAG('R', 'A', 'C', 'E'): + case MKTAG('S', 'C', 'I', 'T'): + case MKTAG('T', 'D', 'V', 'P'): + case MKTAG('T', 'W', 'A', 'T'): + case MKTAG('W', 'E', 'A', 'T'): + tagId = MKTAG('P', 'R', 'S', 'N'); + break; + case MKTAG('C', 'H', 'S', 'E'): + case MKTAG('C', 'M', 'N', 'T'): + case MKTAG('F', 'I', 'L', 'M'): + case MKTAG('J', 'F', 'O', 'D'): + case MKTAG('L', 'I', 'Q', 'D'): + tagId = MKTAG('F', 'O', 'O', 'D'); + break; + case MKTAG('C', 'R', 'M', 'N'): + case MKTAG('C', 'S', 'P', 'Y'): + case MKTAG('U', 'B', 'A', 'D'): + tagId = MKTAG('V', 'B', 'A', 'D'); + break; + case MKTAG('E', 'A', 'R', 'T'): + case MKTAG('H', 'O', 'M', 'E'): + case MKTAG('N', 'P', 'L', 'C'): + case MKTAG('P', 'L', 'A', 'C'): + case MKTAG('P', 'L', 'A', 'N'): + tagId = MKTAG('P', 'L', 'A', 'C'); + break; + case MKTAG('F', 'A', 'U', 'N'): + case MKTAG('F', 'I', 'S', 'H'): + case MKTAG('F', 'L', 'O', 'R'): + tagId = MKTAG('N', 'A', 'T', 'R'); + break; + case MKTAG('H', 'H', 'L', 'D'): + case MKTAG('T', 'O', 'Y', 'S'): + case MKTAG('W', 'E', 'A', 'P'): + tagId = MKTAG('M', 'A', 'C', 'H'); + break; + case MKTAG('M', 'L', 'T', 'Y'): + case MKTAG('P', 'G', 'R', 'P'): + case MKTAG('P', 'T', 'I', 'C'): + tagId = MKTAG('G', 'R', 'U', 'P'); + break; + case MKTAG('P', 'K', 'U', 'P'): + case MKTAG('S', 'E', 'X', '1'): + case MKTAG('S', 'W', 'E', 'R'): + tagId = MKTAG('R', 'U', 'D', 'E'); + break; + case MKTAG('P', 'H', 'I', 'L'): + case MKTAG('R', 'C', 'K', 'T'): + case MKTAG('S', 'C', 'I', 'E'): + tagId = MKTAG('S', 'C', 'I', 'E'); + break; + case MKTAG('T', 'R', 'A', '2'): + case MKTAG('T', 'R', 'A', '3'): + tagId = MKTAG('T', 'R', 'A', 'V'); + break; + default: + break; + } + + if (val == 36) { + switch (getValue(1)) { + case 1: + return setResponse(getDialogueId(220837), -1); + break; + case 2: + return setResponse(getDialogueId(220849), -1); + default: + return setResponse(getDialogueId(220858), -1); + } + } else if (val == 61 && getValue(1) > 2) { + return setResponse(getDialogueId(222301), -1); + } + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); +} + +int BarbotScript::updateState(uint oldId, uint newId, int index) { + if (newId == 250538) { + CTrueTalkManager::triggerAction(28, 0); + return 250538; + } + if (newId == 251704) { + return 251701 + (_field7C ? 3 : 0); + } + + for (uint idx = 0; idx < _states.size(); ++idx) { + const TTupdateState &us = _states[idx]; + if (us._newId == newId) { + if ((us._dialBits & 1) && !getDialRegion(0)) + continue; + if ((us._dialBits & 2) && getDialRegion(0)) + continue; + if ((us._dialBits & 4) && !getDialRegion(1)) + continue; + if ((us._dialBits & 8) && getDialRegion(1)) + continue; + if ((us._dialBits & 0x10) && !getDialRegion(2)) + continue; + if ((us._dialBits & 0x20) && getDialRegion(2)) + continue; + + setState(us._newValue); + break; + } + } + + return newId; +} + +int BarbotScript::preResponse(uint id) { + if (getDialRegion(0) == 0 && getRandomNumber(100) > 80) + return 251250; + + return _preResponses.find(id); +} + +uint BarbotScript::getDialsBitset() const { + uint bits = 0; + if (!getDialRegion(0)) + bits = 1; + if (!getDialRegion(1)) + bits |= 2; + if (!getDialRegion(2)) + bits |= 4; + + return bits; +} + +int BarbotScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + int v34 = getState(); + uint id = 0; + + if (v34 > 0x200) { + switch (v34 - 0x201) { + case 0: + if (getValue(4) != 2) + id = 250738; + break; + case 1: + if (getValue(4) != 3) + id = 250738; + case 2: + if (getValue(4) != 0) + id = 250738; + break; + default: + break; + } + } else if (v34 == 0x200) { + if (getValue(4) != 1) + id = 250738; + } else { + switch (v34) { + case 2: + if (getValue(1) != 1) + return 1; + break; + case 3: + if (getValue(1) != 2) + return 1; + break; + case 4: + if (getValue(1) != 3) + return 1; + break; + case 5: + if (getValue(1) == 3) + return 1; + break; + case 6: + if (sentence->contains("do not") || sentence->contains("have no") || + sentence->contains("got no")) + return 1; + break; + case 7: + if (!sentence->contains("do not") && !sentence->contains("have no") && + !sentence->contains("got no")) + return 1; + break; + case 8: + if (sentence->_field38 == 2) + return 1; + break; + case 9: { + uint val = CTrueTalkManager::getStateValue(3); + bool bit0 = (val & 1) != 0; + bool bit2 = (val & 4) != 0; + bool bit3 = (val & 8) != 0; + + if (bit2) { + if (!bit0) { + id = 250085 - (bit3 ? 0 : 199715); + break; + } else if (!bit3) { + id = 250627; + } + } else { + if (!bit0) { + id = 50365 + (bit3 ? 0 : 2); + } else if (!bit3) { + id = 50370; + } + } + + if (id) { + addResponse(getDialogueId(id)); + applyResponse(); + return 2; + } + break; + } + + case 10: { + uint val = CTrueTalkManager::getStateValue(3); + bool bit0 = (val & 1) != 0; + bool bit2 = (val & 4) != 0; + bool bit3 = (val & 8) != 0; + + if (bit0 && bit2 && bit3) { + addResponse(getDialogueId(251027)); + applyResponse(); + CTrueTalkManager::triggerAction(7, 0); + return 2; + } else { + if (getDialRegion(1) == 1) { + if (*srcIdP != 251650) + id = 251651; + } else { + addResponse(getDialRegion(0) != 0 ? 51444 : 51530); + applyResponse(); + return 2; + } + } + break; + } + + case 11: + if (CTrueTalkManager::getStateValue(2) != 0) { + CTrueTalkManager::triggerAction(6, 0); + id = 251003; + } + break; + + case 12: + if (getDialRegion(1) == 0) { + addResponse(getDialogueId(251871)); + applyResponse(); + return 2; + } else if (getRandomNumber(100) > 25 && addRandomResponse(false)) { + return 2; + } + + default: + break; + } + } + + if (id) { + addResponse(getDialogueId(id)); + applyResponse(); + } + + return 2; +} + +void BarbotScript::setDialRegion(int dialNum, int region) { + TTnpcScript::setDialRegion(dialNum, region); + selectResponse(250365); + applyResponse(); +} + +void BarbotScript::adjustDial(int dialNum, int amount) { + int level = CLIP(getDialLevel(dialNum) + amount, 0, 100); + setDial(dialNum, level); +} + +bool BarbotScript::isState9() const { + return CTrueTalkManager::getStateValue(9) != 0; +} + +int BarbotScript::applySentenceIds(int dialogueId, int v34) { + addResponse(dialogueId); + applyResponse(); + + if (v34 != -1) { + setState(v34); + } else { + for (uint idx = 0; idx < _mappings.size(); ++idx) { + const TTscriptMapping &m = _mappings[idx]; + for (int vidx = 0; vidx < _mappings._valuesPerMapping; ++idx) { + if (m._values[vidx] == (uint)dialogueId) { + updateState(m._id, m._id, vidx); + break; + } + } + } + } + + return -2; +} + +int BarbotScript::setResponse(int dialogueId, int state) { + addResponse(dialogueId); + applyResponse(); + + if (state != -1) + setState(state); + return 2; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/barbot_script.h b/engines/titanic/true_talk/barbot_script.h new file mode 100644 index 0000000000..1820d77216 --- /dev/null +++ b/engines/titanic/true_talk/barbot_script.h @@ -0,0 +1,106 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BARBOT_SCRIPT_H +#define TITANIC_BARBOT_SCRIPT_H + +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class BarbotScript : public TTnpcScript { +private: + int _state; + int _arrIndex; + TTsentenceEntries _entries2; + TTupdateStateArray _states; + TTmapEntryArray _preResponses; +private: + /** + * Adjust a given dial number by a given delta amount + */ + void adjustDial(int dialNum, int amount); + + /** + * Setup sentence data + */ + void setupSentences(); + + bool isState9() const; + + int applySentenceIds(int dialogueId, int v34 = -1); + + /** + * Add a response and optionally set the state + */ + int setResponse(int dialogueId, int state = -1); +public: + BarbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + virtual int handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + + /** + * Returns a bitset of the first three dialgs being on or not + */ + virtual uint getDialsBitset() const; + + /** + * Process a sentence fragment entry + */ + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Sets a given dial to be pointing in a specified region (0 to 2) + */ + virtual void setDialRegion(int dialNum, int region); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BARBOT_SCRIPT_H */ diff --git a/engines/titanic/true_talk/bellbot_script.cpp b/engines/titanic/true_talk/bellbot_script.cpp new file mode 100644 index 0000000000..7da2ab6201 --- /dev/null +++ b/engines/titanic/true_talk/bellbot_script.cpp @@ -0,0 +1,1905 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/bellbot_script.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/core/node_item.h" +#include "titanic/titanic.h" + +namespace Titanic { + +uint BellbotScript::_oldId; + +static const RoomDialogueId ROOM_DIALOGUE_IDS[] = { + { 100, 201442 },{ 101, 201417 },{ 107, 201491 },{ 108, 201421 }, + { 109, 201437 },{ 110, 201431 },{ 111, 201457 },{ 112, 201411 }, + { 113, 201424 },{ 114, 201464 },{ 115, 201407 },{ 116, 201468 }, + { 117, 201447 },{ 122, 201491 },{ 123, 201299 },{ 124, 201479 }, + { 125, 201480 },{ 126, 201476 },{ 127, 201483 },{ 128, 201399 }, + { 129, 201400 },{ 130, 201387 },{ 131, 201395 },{ 132, 201388 }, + { 0, 0 } +}; + +BellbotScript::BellbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, -1, -1, -1, 0), + _field2D0(0), _field2D4(0), _field2D8(0), _field2DC(0), + _room107First(false) { + CTrueTalkManager::setFlags(25, 0); + CTrueTalkManager::setFlags(24, 0); + CTrueTalkManager::setFlags(40, 0); + CTrueTalkManager::setFlags(26, 0); + + setupDials(0, 0, 0); + _array[0] = 100; + _array[1] = 0; + + loadRanges("Ranges/Bellbot"); + loadResponses("Responses/Bellbot", 4); + setupSentences(); + _tagMappings.load("TagMap/Bellbot"); + _words.load("Words/Bellbot"); + _quotes.load("Quotes/Bellbot"); + _states.load("States/Bellbot"); + _preResponses.load("PreResponses/Bellbot"); + _phrases.load("Phrases/Bellbot"); +} + +void BellbotScript::setupSentences() { + _mappings.load("Mappings/Bellbot", 1); + _entries.load("Sentences/Bellbot"); + for (int idx = 1; idx < 20; ++idx) + _sentences[idx].load(CString::format("Sentences/Bellbot/%d", idx)); + + _field2DC = 0; + _field68 = 0; + _entryCount = 0; +} + +int BellbotScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + int val24 = getValue(24); + CTrueTalkManager::setFlags(24, 0); + + int result = preprocess(roomScript, sentence); + if (result != 1) + return 1; + + CTrueTalkManager::setFlags(23, 0); + setState(0); + if (getValue(1) <= 2) + updateCurrentDial(1); + + // Handle room specific sentences + switch (roomScript->_scriptId) { + case 101: + if (getValue(2) == 1) { + result = processEntries(&_sentences[11], 0, roomScript, sentence); + } + break; + + case 107: + result = processEntries(&_sentences[5], 0, roomScript, sentence); + break; + + case 108: + result = processEntries(&_sentences[7], 0, roomScript, sentence); + break; + + case 109: + result = processEntries(&_sentences[13], 0, roomScript, sentence); + break; + + case 110: + result = processEntries(&_sentences[16], 0, roomScript, sentence); + break; + + case 111: + result = processEntries(&_sentences[10], 0, roomScript, sentence); + break; + + case 112: + result = processEntries(&_sentences[15], 0, roomScript, sentence); + break; + + case 113: + result = processEntries(&_sentences[9], 0, roomScript, sentence); + break; + + case 114: + result = processEntries(&_sentences[18], 0, roomScript, sentence); + break; + + case 115: + result = processEntries(&_sentences[12], 0, roomScript, sentence); + break; + + case 116: + result = processEntries(&_sentences[8], 0, roomScript, sentence); + break; + + case 117: + result = processEntries(&_sentences[6], 0, roomScript, sentence); + break; + + case 123: + result = processEntries(&_sentences[17], 0, roomScript, sentence); + break; + + case 125: + result = processEntries(&_sentences[14], 0, roomScript, sentence); + break; + + case 131: + if (getValue(26) == 0) { + result = processEntries(&_sentences[getValue(6) ? 5 : 4], 0, roomScript, sentence); + } + break; + } + + if (result == 2) + return 2; + if (sentence->contains("pretend you summoned yourself") || + sentence->contains("pretend you just summoned yourself")) { + if (scriptChanged(roomScript, 157) == 2) + return 2; + } + + if (sentence->localWord("television") || roomScript->_scriptId == 111) { + if (sentence->localWord("drop") || sentence->localWord("throw") + || sentence->localWord("smash") || sentence->localWord("destroy") + || sentence->localWord("toss") || sentence->localWord("put") + || sentence->localWord("pitch") || sentence->localWord("heft")) { + if (getValue(40) == 1) { + addResponse(getDialogueId(201687)); + applyResponse(); + return 2; + } + else if (roomScript->_scriptId == 111) { + addResponse(getDialogueId(201687)); + applyResponse(); + CTrueTalkManager::triggerAction(17, 0); + CTrueTalkManager::setFlags(40, 1); + return 2; + } + else { + addResponse(getDialogueId(200710)); + addResponse(getDialogueId(201334)); + applyResponse(); + return 2; + } + } + } + + if (sentence->contains("what should i do here") + || sentence->contains("what do i do here") + || sentence->contains("what shall i do in here") + || sentence->contains("what shall i do in this room") + || sentence->contains("what should i do in this room") + || sentence->contains("what am i supposed to do in here") + || sentence->contains("what should i do in here") + || sentence->contains("what do i do in this room")) { + if (addRoomDescription(roomScript)) { + applyResponse(); + return 2; + } + } + + if (sentence->contains("help") + || sentence->contains("what now") + || sentence->contains("what next") + || sentence->contains("give me a hint") + || sentence->contains("i need a hint") + || sentence->contains("what should i be doing") + || sentence->contains("what do you reckon i should do now") + || sentence->contains("what shall i do") + || sentence->contains("what would you do") + || sentence->contains("what should i do") + || sentence->contains("what do i do")) { + if (getDialRegion(0) == 1) { + randomResponse4(roomScript, getValue(1)); + applyResponse(); + return 2; + } else { + randomResponse3(roomScript, getValue(1)); + } + } + + if (sentence->get58() > 6 && sentence->contains("please")) { + addResponse(getDialogueId(200432)); + applyResponse(); + return 2; + } + + if (checkCommonSentences(roomScript, sentence) == 2) + return 2; + + // WORKAROUND: Skip processEntries call on unassigned sentence array + + // Standard sentence list + if (processEntries(&_entries, _entryCount, roomScript, sentence) == 2) + return 2; + + if ((sentence->_field2C == 4 && sentence->localWord("am") && sentence->localWord("i")) + || (sentence->localWord("are") && sentence->localWord("we")) + || (sentence->_field2C == 3 && sentence->localWord("room") + && sentence->localWord("we") && sentence->localWord("in")) + || (sentence->_field2C == 3 && sentence->localWord("rom") + && sentence->localWord("is") && sentence->localWord("this")) + ) { + uint id = getRangeValue(getRoomDialogueId(roomScript)); + addResponse(getDialogueId(id ? id : 201384)); + applyResponse(); + return 2; + } + + if (getValue(1) >= 3) { + result = processEntries(&_sentences[1], 0, roomScript, sentence); + } else if (getValue(1) == 2) { + result = processEntries(&_sentences[2], 0, roomScript, sentence); + } else if (getValue(1) == 1) { + result = processEntries(&_sentences[3], 0, roomScript, sentence); + + if (sentence->contains("shrinkbot")) { + addResponse(getDialogueId(200583)); + applyResponse(); + return 2; + } + } + + if (sentence->localWord("television") || sentence->localWord("tv") + || sentence->localWord("crush") || sentence->localWord("crushed")) { + if (roomScript->_scriptId == 111 || getRandomBit()) { + addResponse(getDialogueId(getRandomBit() ? 200912 : 200913)); + } else { + addResponse(getDialogueId(200710)); + addResponse(getDialogueId(201334)); + } + + applyResponse(); + return 2; + } + + if (checkCommonWords(roomScript, sentence)) { + applyResponse(); + setState(0); + return 2; + } + + if (sentence->contains("my") && (sentence->contains("where can i find") + || sentence->contains("where is") + || sentence->contains("wheres") + || sentence->contains("help me find") + || sentence->contains("what have you done with") + || sentence->contains("have you got") + || sentence->contains("id like") + || sentence->contains("i would like") + || sentence->contains("have you seen") + )) { + addResponse(getDialogueId(200799)); + applyResponse(); + return 2; + } + + setupSentences(); + uint tagId = g_vm->_trueTalkManager->_quotes.find(sentence->_normalizedLine); + if (tagId && chooseResponse(roomScript, sentence, tagId) == 2) + return 2; + if (defaultProcess(roomScript, sentence)) + return 2; + if (!processEntries(&_sentences[19], 0, roomScript, sentence)) + return 2; + if (!processEntries(_defaultEntries, 0, roomScript, sentence)) + return 2; + + if (sentence->contains("42")) { + addResponse(getDialogueId(200515)); + applyResponse(); + return 2; + } + + CTrueTalkManager::setFlags(24, val24 + 1); + if (getValue(24) > 3) { + addResponse(getDialogueId(200200)); + applyResponse(); + return 2; + } + + if (sentence->localWord("get")) { + addResponse(getDialogueId(200475)); + applyResponse(); + return 2; + } + + if (getRandomNumber(100) <= 75) { + addResponse(getDialogueId(200060)); + applyResponse(); + return 2; + } + + addResponse(getDialogueId(200140)); + addResponse(getDialogueId(getRandomBit() ? 200192 : 200157)); + addResponse(getDialogueId(200176)); + applyResponse(); + return 2; +} + +ScriptChangedResult BellbotScript::scriptChanged(const TTroomScript *roomScript, uint id) { + if (!roomScript) + return SCR_2; + + switch (id) { + case 104: + addResponse(getDialogueId(200617)); + applyResponse(); + break; + + case 105: + addResponse(getDialogueId(200732)); + applyResponse(); + break; + + case 106: + addResponse(getDialogueId(200733)); + applyResponse(); + break; + + case 107: + addResponse(getDialogueId(200731)); + applyResponse(); + break; + + case 157: + _field2DC = 1; + break; + + case 158: + CTrueTalkManager::setFlags(26, 1); + break; + + case 3: + if (_field2DC) { + if (randomResponse0(roomScript, id)) + return SCR_2; + } else { + addResponse(getDialogueId(201693)); + applyResponse(); + } + + _field2DC = 0; + CTrueTalkManager::_v9 = 0; + // Deliberate fall-through + default: + if (roomScript->_scriptId == 115 && id == 103) { + switch (getValue(4)) { + case 0: + addResponse(getDialogueId(200014)); + applyResponse(); + break; + case 1: + case 2: + addResponse(getDialogueId(200011)); + applyResponse(); + break; + case 3: + addResponse(getDialogueId(200007)); + applyResponse(); + break; + default: + break; + } + } + break; + } + + return SCR_2; +} + +int BellbotScript::handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder) { + switch (tagId) { + case MKTAG('A', 'D', 'V', 'T'): + case MKTAG('A', 'R', 'T', 'I'): + case MKTAG('A', 'R', 'T', 'Y'): + case MKTAG('B', 'R', 'N', 'D'): + case MKTAG('C', 'O', 'M', 'D'): + case MKTAG('D', 'N', 'C', 'E'): + case MKTAG('H', 'B', 'B', 'Y'): + case MKTAG('L', 'I', 'T', 'R'): + case MKTAG('M', 'A', 'G', 'S'): + case MKTAG('M', 'C', 'P', 'Y'): + case MKTAG('M', 'I', 'N', 'S'): + case MKTAG('M', 'U', 'S', 'I'): + case MKTAG('N', 'I', 'K', 'E'): + case MKTAG('S', 'F', 'S', 'F'): + case MKTAG('S', 'O', 'A', 'P'): + case MKTAG('S', 'O', 'N', 'G'): + case MKTAG('S', 'P', 'R', 'T'): + case MKTAG('T', 'E', 'A', 'M'): + case MKTAG('T', 'V', 'S', 'H'): + case MKTAG('W', 'W', 'E', 'B'): + tagId = MKTAG('E', 'N', 'T', 'N'); + break; + case MKTAG('A', 'C', 'T', 'R'): + case MKTAG('A', 'C', 'T', 'S'): + case MKTAG('A', 'U', 'T', 'H'): + case MKTAG('B', 'A', 'R', 'K'): + case MKTAG('B', 'A', 'R', 'U'): + case MKTAG('B', 'L', 'F', '1'): + case MKTAG('B', 'L', 'F', '2'): + case MKTAG('B', 'L', 'P', '1'): + case MKTAG('B', 'L', 'P', '2'): + case MKTAG('B', 'L', 'P', '3'): + case MKTAG('B', 'L', 'P', '4'): + case MKTAG('B', 'L', 'R', '1'): + case MKTAG('B', 'L', 'R', '2'): + case MKTAG('B', 'L', 'T', '1'): + case MKTAG('B', 'L', 'T', '2'): + case MKTAG('B', 'L', 'T', '3'): + case MKTAG('B', 'L', 'T', '4'): + case MKTAG('B', 'L', 'T', '5'): + case MKTAG('C', 'O', 'P', 'S'): + case MKTAG('D', 'C', 'T', 'R'): + case MKTAG('F', 'A', 'S', 'H'): + case MKTAG('F', 'A', 'M', 'E'): + case MKTAG('H', 'E', 'R', 'D'): + case MKTAG('H', 'O', 'S', 'T'): + case MKTAG('K', 'N', 'O', 'B'): + case MKTAG('N', 'H', 'R', 'O'): + case MKTAG('R', 'A', 'C', 'E'): + case MKTAG('S', 'C', 'I', 'T'): + case MKTAG('T', 'O', 'U', 'P'): + case MKTAG('T', 'W', 'A', 'T'): + case MKTAG('W', 'E', 'A', 'T'): + tagId = MKTAG('P', 'R', 'S', 'N'); + break; + case MKTAG('C', 'H', 'S', 'E'): + case MKTAG('C', 'M', 'N', 't'): + case MKTAG('F', 'I', 'L', 'M'): + case MKTAG('J', 'F', 'O', 'D'): + case MKTAG('L', 'I', 'Q', 'D'): + tagId = MKTAG('F', 'O', 'O', 'D'); + break; + case MKTAG('C', 'R', 'I', 'M'): + case MKTAG('C', 'S', 'P', 'Y'): + case MKTAG('D', 'R', 'U', 'G'): + tagId = MKTAG('V', 'B', 'A', 'D'); + break; + case MKTAG('E', 'A', 'R', 'T'): + case MKTAG('H', 'O', 'M', 'E'): + case MKTAG('N', 'P', 'L', 'C'): + case MKTAG('P', 'L', 'A', 'N'): + tagId = MKTAG('P', 'L', 'A', 'C'); + break; + case MKTAG('F', 'A', 'U', 'N'): + case MKTAG('F', 'I', 'S', 'H'): + case MKTAG('F', 'L', 'O', 'R'): + tagId = MKTAG('N', 'A', 'T', 'R'); + break; + case MKTAG('H', 'H', 'L', 'D'): + case MKTAG('T', 'O', 'Y', 'S'): + case MKTAG('W', 'E', 'A', 'P'): + tagId = MKTAG('M', 'A', 'C', 'H'); + break; + case MKTAG('M', 'L', 'T', 'Y'): + case MKTAG('P', 'G', 'R', 'P'): + case MKTAG('P', 'T', 'I', 'C'): + tagId = MKTAG('G', 'R', 'U', 'P'); + break; + case MKTAG('P', 'K', 'U', 'P'): + case MKTAG('S', 'E', 'X', '1'): + case MKTAG('S', 'W', 'E', 'R'): + tagId = MKTAG('R', 'U', 'D', 'E'); + break; + case MKTAG('P', 'H', 'I', 'L'): + case MKTAG('R', 'C', 'K', 'T'): + tagId = MKTAG('S', 'C', 'I', 'E'); + break; + case MKTAG('T', 'R', 'A', '2'): + case MKTAG('T', 'R', 'A', '3'): + tagId = MKTAG('T', 'R', 'A', 'V'); + break; + default: + break; + } + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); +} + +int BellbotScript::updateState(uint oldId, uint newId, int index) { + if (!getValue(25)) { + newId = 202043 - getValue(1) <= 2 ? 994 : 0; + CTrueTalkManager::setFlags(25, 1); + } + + if (oldId == _oldId && _rangeResetCtr >= 3) { + TTscriptRange *range = findRange(oldId); + if (range) + range->_priorIndex = 0; + + _rangeResetCtr = 0; + return getRangeValue(200370); + } + + if (oldId != _oldId) { + _oldId = oldId; + _rangeResetCtr = 0; + } + + if (oldId >= 201709 && oldId <= 201754) { + addResponse(getDialogueId(201705)); + addResponse(getDialogueId(201706)); + newId = getRangeValue(201707); + } + + if (newId == 202276) + newId = addLocation(); + if (newId == 202275) + newId = getStateDialogueId(); + + if (getValue(1) >= 2) { + if (newId == 200840 || newId == 200845 || newId == 200846 || newId == 200851) { + if (getValue(1) == 2) { + newId = 202047; + } else { + newId = getRangeValue(202848); + } + } + } + + if (getValue(1) >= 3) { + if (newId == 200841 || newId == 200842 || newId == 200843 || + newId == 200847 || newId == 200848 || newId == 200854) { + newId = getRangeValue(202038); + } + } + + if (newId == 200264 && getValue(1) == 1) + newId = 200267; + if (newId == 202231 && getValue(1) == 1) + newId = 200848; + + int v4 = getValue(4); + if (newId == 200187 && v4) { + return 200188; + } else if (newId == 200188 && !v4) { + return 200187; + } else if (newId == 200014 && (v4 == 1 || v4 == 2)) { + return 200011; + } else if (newId == 200011 && !v4) { + return 200014; + } + + if (oldId == 200612) { + CTrueTalkManager::setFlags(25, 2); + CTrueTalkManager::setFlags(5, 1); + } + + if (newId == 200423 || newId == 200424 || newId == 200425) { + if (getValue(5)) { + CTrueTalkManager::triggerAction(16, 0); + } else { + newId = 200611; + } + } + + if (oldId == 200261 && getRandomNumber(10) == 1) { + if (getValue(1) >= 3) + newId = getRangeValue(200283); + else if (getValue(1) == 2) + newId = getRangeValue(200279); + } + + if (oldId == 200962) { + if (getValue(1) == 2) + return 200963; + if (getValue(1) == 1) + return 200964; + } + if (oldId == 200989 && getValue(1) <= 2) + return 200990; + + if (oldId == 201760) { + CGameManager *gameManager = g_vm->_trueTalkManager->getGameManager(); + CPetControl *pet = getPetControl(gameManager); + + if (pet) { + bool canSummon = pet->canSummonBot("DoorBot"); + if (canSummon) { + CTrueTalkManager::_v9 = 101; + CTrueTalkManager::triggerAction(5, 0); + } else { + newId = 201857; + } + } + } + + setValue23(newId); + return newId; +} + +int BellbotScript::preResponse(uint id) { + int newId = _preResponses.find(id); + + if (newId == 202277) { + applyResponse(); + CTrueTalkManager::triggerAction(1, 0); + } + if (newId == 200769) { + applyResponse(); + CTrueTalkManager::triggerAction(18, 0); + } + + if (id == 21790) + CTrueTalkManager::triggerAction(13, 0); + + return newId; +} + +int BellbotScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + switch (val1) { + case 1: + addResponse(getDialogueId(*srcIdP)); + applyResponse(); + return 2; + + case 2: + addResponse(getDialogueId(*srcIdP)); + addResponse(getDialogueId(getRandomNumber(2) == 1 ? 200192 : 200157)); + addResponse(getDialogueId(200176)); + applyResponse(); + return 2; + + case 21: + if (CTrueTalkManager::getStateValue(7) == 0) { + selectResponse(21372); + applyResponse(); + return 2; + } + + if (!sentence->localWord("broken") && !sentence->contains("broken") && + CTrueTalkManager::_currentNPC) { + CNodeItem *node = CTrueTalkManager::_currentNPC->getNode(); + if (node) { + CString nodeName = node->getName(); + if (nodeName == "5" || nodeName == "6" || nodeName == "7") { + CTrueTalkManager::triggerAction(29, 2); + selectResponse(201571); + applyResponse(); + return 2; + } + } + } + + CTrueTalkManager::triggerAction(29, 1); + selectResponse(201771); + applyResponse(); + return 2; + + case 22: + if (CTrueTalkManager::getStateValue(7) == 0) { + selectResponse(21372); + applyResponse(); + return 2; + } + + if (!sentence->localWord("broken") && !sentence->contains("broken") && + CTrueTalkManager::_currentNPC) { + CNodeItem *node = CTrueTalkManager::_currentNPC->getNode(); + if (node) { + CString nodeName = node->getName(); + if (nodeName == "5" || nodeName == "6" || nodeName != "7") { + CTrueTalkManager::triggerAction(29, 2); + selectResponse(201571); + applyResponse(); + return 2; + } + } + } + + CTrueTalkManager::triggerAction(29, 1); + selectResponse(201771); + applyResponse(); + return 2; + + case 23: + case 24: + if (CTrueTalkManager::getStateValue(7) == 0) { + selectResponse(21372); + applyResponse(); + return 2; + } + + CTrueTalkManager::triggerAction(29, val1 == 23 ? 3 : 4); + break; + + default: + break; + } + + return 0; +} + +bool BellbotScript::randomResponse(uint index) { + if (getRandomNumber(100) > 10 || getRandomNumber(10) <= index) + return 0; + + if (getRandomNumber(100) > 95) { + deleteResponses(); + addResponse(getDialogueId(201695)); + applyResponse(); + } else { + setResponseFromArray(index, 201696); + } + + return true; +} + +int BellbotScript::addLocation() { + addResponse(getDialogueId(202228)); + int roomNum, floorNum, elevatorNum; + getAssignedRoom(&roomNum, &floorNum, &elevatorNum); + + addResponse(getDialogueId(202071 + roomNum)); + addResponse(getDialogueId(201933 + floorNum)); + addResponse(getDialogueId(201916 + elevatorNum)); + + return 200858; +} + +int BellbotScript::getStateDialogueId() const { + switch (getValue(1)) { + case 1: + return 201253; + case 2: + return 200282; + default: + return 201246; + } +} + +void BellbotScript::setValue23(uint id) { + uint val = 0; + for (uint idx = 0; idx < _states.size() && !val; ++idx) { + TTmapEntry &us = _states[idx]; + if (us._src == id) + val = us._dest; + } + + CTrueTalkManager::setFlags(23, val); +} + +int BellbotScript::preprocess(const TTroomScript *roomScript, const TTsentence *sentence) { + if (!roomScript || !sentence) + return true; + + bool applyFlag = false, stateFlag = true; + switch (getValue(23)) { + case 1: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200818)); + applyFlag = true; + } + if (sentence->_field2C == 12) { + addResponse(getDialogueId(200817)); + applyFlag = true; + } + break; + + case 2: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200835)); + addResponse(getDialogueId(200830)); + applyFlag = true; + } else if (sentence->_field2C == 12) { + addResponse(getDialogueId(200834)); + addResponse(getDialogueId(200830)); + applyFlag = true; + } + break; + + case 3: + if (sentence->_field2C >= 11 && sentence->_field2C <= 13) { + addResponse(getDialogueId(200831)); + addResponse(getDialogueId(200833)); + applyFlag = true; + } + break; + + case 4: + if (sentence->_field2C == 11) { + addResponse(getDialogueId(200872)); + applyFlag = true; + } + if (sentence->_field2C == 12 || sentence->_field2C == 13) { + addResponse(getDialogueId(200873)); + applyFlag = true; + } + break; + + case 5: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200492)); + applyFlag = true; + } + if (sentence->_field2C == 12) { + addResponse(getDialogueId(200491)); + applyFlag = true; + } + break; + + case 6: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200496)); + applyResponse(); + setState(0); + CTrueTalkManager::setFlags(23, 7); + return 2; + } + if (sentence->_field2C == 12) { + addResponse(getDialogueId(200127)); + applyFlag = true; + } + break; + + case 7: + addResponse(getDialogueId(200504)); + addResponse(getDialogueId(200496)); + applyFlag = true; + stateFlag = false; + break; + + case 8: + addResponse(getDialogueId(200494)); + applyFlag = true; + stateFlag = false; + break; + + case 9: + addResponse(getDialogueId(sentence->localWord("guess") ? 200495 : 200493)); + applyFlag = true; + break; + + case 10: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200317)); + applyResponse(); + setState(0); + CTrueTalkManager::setFlags(23, 11); + return 2; + } + + addResponse(getDialogueId(sentence->_field2C == 12 ? 200316 : 200315)); + applyFlag = true; + break; + + case 11: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200055)); + } else if (sentence->_field2C == 12) { + addResponse(getDialogueId(200318)); + } else { + addResponse(getDialogueId(200315)); + } + + applyFlag = true; + break; + + case 12: + if (sentence->_field2C == 6) { + addResponse(getDialogueId(200259)); + applyFlag = true; + } + break; + + case 13: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200207)); + applyFlag = true; + } else if (sentence->_field2C == 12) { + addResponse(getDialogueId(200206)); + applyFlag = true; + } + break; + + case 14: + if (sentence->_field2C == 6) { + addResponse(getDialogueId(200349)); + applyFlag = true; + } + + case 15: + if (sentence->_field2C == 6) { + addResponse(getDialogueId(200130)); + applyResponse(); + setState(0); + CTrueTalkManager::setFlags(23, 16); + return 2; + } + break; + + case 16: + if (sentence->localWord("invented")) { + addResponse(getDialogueId(200131)); + applyFlag = true; + } + break; + + case 17: + if ((sentence->_field2C == 3 && sentence->localWord("code")) + || (sentence->localWord("which") && sentence->localWord("is")) + || sentence->localWord("remember") + || sentence->localWord("know") + ) { + addResponse(getDialogueId(200044)); + applyFlag = true; + stateFlag = false; + } + break; + + case 19: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200223)); + applyFlag = true; + } + break; + + case 20: + addResponse(getDialogueId(200254)); + applyFlag = true; + break; + + case 21: + if (sentence->contains("hiker") || sentence->contains("hug")) { + addResponse(getDialogueId(200379)); + applyFlag = true; + } + break; + + case 22: + if (sentence->localWord("get") || sentence->localWord("it")) { + addResponse(getDialogueId(200474)); + applyFlag = true; + } + break; + + case 23: + addResponse(getDialogueId(sentence->localWord("long") ? 200870 : 200871)); + applyFlag = true; + break; + + case 24: + addResponse(getDialogueId(200793)); + applyFlag = true; + stateFlag = false; + break; + + case 25: + if (sentence->localWord("parrot")) { + addResponse(getDialogueId(200255)); + applyFlag = true; + stateFlag = false; + } + break; + + case 26: + if (sentence->localWord("cage")) { + addResponse(getDialogueId(200380)); + applyFlag = true; + stateFlag = false; + } + break; + + case 27: + addResponse(getDialogueId(200347)); + applyFlag = true; + stateFlag = false; + break; + + case 28: + if (sentence->localWord("perch")) { + addResponse(getDialogueId(200242)); + applyFlag = true; + stateFlag = false; + } + break; + + case 29: + if (sentence->localWord("brain") || sentence->localWord("titania")) { + addResponse(getDialogueId(200392)); + applyFlag = true; + stateFlag = false; + } + break; + + case 30: + if ((sentence->localWord("did") || sentence->localWord("not")) + || (sentence->localWord("would") || sentence->localWord("not")) + || (sentence->localWord("could") || sentence->localWord("not")) + || sentence->localWord("tried")) { + addResponse(getDialogueId(200416)); + applyFlag = true; + } + break; + + case 31: + addResponse(getDialogueId(sentence->_field2C == 11 ? 200810 : 200811)); + applyFlag = true; + break; + + case 32: + addResponse(getDialogueId(sentence->_field2C == 11 ? 200810 : 200812)); + applyFlag = true; + break; + + case 33: + addResponse(getDialogueId(200822)); + applyFlag = true; + break; + + case 34: + addResponse(getDialogueId(200824)); + applyFlag = true; + break; + + case 35: + if (sentence->_field2C == 3 && sentence->localWord("it") + && (sentence->localWord("for") || sentence->localWord("do"))) { + addResponse(getDialogueId(200768)); + applyFlag = true; + } + break; + + case 36: + if (sentence->_field2C == 11) { + CTrueTalkManager::triggerAction(14, 0); + addResponse(getDialogueId(200761)); + applyFlag = true; + } + break; + + case 37: + addResponse(getDialogueId(200630)); + applyFlag = true; + break; + + case 38: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(200631)); + applyFlag = true; + } + break; + + case 39: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200632)); + stateFlag = false; + } else { + addResponse(getDialogueId(200633)); + } + applyFlag = true; + break; + + case 40: + addResponse(getDialogueId(200633)); + applyFlag = true; + break; + + case 41: + addResponse(getDialogueId(sentence->contains("42") ? 200139 : 200627)); + applyFlag = true; + break; + + case 42: + if ((sentence->localWord("carry") && sentence->localWord("on")) + || (sentence->localWord("go") && sentence->localWord("on")) + || sentence->localWord("more") + || sentence->localWord("going") + || sentence->localWord("elaborate") + || sentence->localWord("suspicious") + || sentence->localWord("they")) { + addResponse(getDialogueId(200642)); + applyFlag = true; + stateFlag = false; + } + break; + + case 43: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200643)); + applyFlag = true; + } + break; + + case 44: +case44: + if (better(sentence, 200615, 200613)) { + applyFlag = true; + stateFlag = false; + } + break; + + case 45: + if (sentence->contains("surprise")) { + addResponse(getDialogueId(200614)); + applyFlag = true; + stateFlag = false; + break; + } + goto case44; + + case 46: + if (sentence->contains("good")) { + addResponse(getDialogueId(200616)); + applyFlag = true; + stateFlag = false; + break; + } + goto case44; + + case 47: + if (sentence->_field2C == 12) + addResponse(getDialogueId(200368)); + addResponse(getDialogueId(200366)); + applyFlag = true; + stateFlag = false; + break; + + case 48: + if ((sentence->localWord("carry") && sentence->localWord("on")) + || sentence->localWord("more") + || (sentence->localWord("go") && sentence->localWord("on")) + || sentence->localWord("going") + || sentence->localWord("yes") + || sentence->localWord("really")) { + addResponse(getDialogueId(200367)); + applyFlag = true; + } + break; + + case 49: + if (sentence->_field2C >= 11 && sentence->_field2C <= 13) { + addResponse(getDialogueId(200407)); + applyFlag = true; + stateFlag = false; + } + break; + + case 50: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200408)); + stateFlag = false; + } else { + addResponse(getDialogueId(200409)); + } + applyFlag = true; + break; + + case 51: + if (sentence->localWord("no") || sentence->localWord("it") + || sentence->localWord("is") || sentence->localWord("not") + || sentence->contains("yeah right")) { + addResponse(getDialogueId(200636)); + applyFlag = true; + } + break; + + case 52: + if (sentence->_field2C >= 11 && sentence->_field2C <= 13) { + addResponse(getDialogueId(200872)); + applyFlag = true; + } + break; + + case 53: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(200525)); + applyFlag = true; + } else if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200526)); + applyFlag = true; + } + break; + + case 54: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(200095)); + applyFlag = true; + stateFlag = false; + } + break; + + case 55: + if (sentence->_field2C == 6) { + addResponse(getDialogueId(200112)); + applyFlag = true; + } + break; + + case 56: + if (sentence->localWord("sure") + || (sentence->localWord("nothing") && sentence->localWord("else"))) { + addResponse(getDialogueId(200649)); + applyFlag = true; + stateFlag = false; + } + break; + + case 57: + if (sentence->localWord("bad") + || (sentence->localWord("not") && sentence->localWord("good"))) { + addResponse(getDialogueId(200654)); + } else { + addResponse(getDialogueId(200655)); + stateFlag = false; + } + applyFlag = true; + break; + + case 58: + if (sentence->localWord("more") + || (sentence->localWord("go") && sentence->localWord("on")) + || (sentence->_field2C == 11 && sentence->localWord("really"))) { + addResponse(getDialogueId(200650)); + applyFlag = true; + stateFlag = false; + } + break; + + case 59: + if (!sentence->localWord("shutup")) { + addResponse(getDialogueId(200651)); + applyFlag = true; + stateFlag = false; + } + break; + + case 60: + if (sentence->_field2C == 3 && sentence->localWord("they") && sentence->localWord("do")) { + addResponse(getDialogueId(200652)); + applyFlag = true; +stateFlag = false; + } + break; + + case 61: + if ((sentence->localWord("that") && sentence->localWord("all")) + || (sentence->localWord("anything") && sentence->localWord("else"))) { + addResponse(getDialogueId(200653)); + applyFlag = true; + } + break; + + case 62: + if (sentence->localWord("meant") || sentence->localWord("woman")) { + addResponse(getDialogueId(200743)); + applyFlag = true; + } + break; + + case 63: + addResponse(getDialogueId(200208)); + applyFlag = true; + break; + + case 64: + if (sentence->localWord("rowboat")) { + addResponse(getDialogueId(200052)); + applyFlag = true; + } + break; + + case 65: + if (sentence->localWord("sorry")) { + addResponse(getDialogueId(200056)); + applyFlag = true; + stateFlag = false; + } + break; + + case 66: + if (sentence->localWord("sorry")) { + addResponse(getDialogueId(200057)); + applyFlag = true; + stateFlag = false; + } + break; + + case 67: + if (sentence->localWord("sorry")) { + addResponse(getDialogueId(200055)); + applyFlag = true; + stateFlag = false; + } + break; + + case 68: + if ((sentence->localWord("i") && sentence->localWord("care")) + || sentence->localWord("do") + || sentence->localWord("me")) { + addResponse(getDialogueId(201006)); + applyFlag = true; + } + break; + + case 69: + if ((sentence->localWord("what") && sentence->localWord("happen")) + || sentence->localWord("filigon")) { + addResponse(getDialogueId(201011)); + applyFlag = true; + stateFlag = false; + } + break; + + case 70: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(201012)); + applyFlag = true; + stateFlag = false; + } + break; + + case 71: + if (sentence->localWord("why")) { + addResponse(getDialogueId(201013)); + applyFlag = true; + } + break; + + case 72: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(200921)); + applyFlag = true; + } else if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(200920)); + applyFlag = true; + } + break; + + case 73: + if (sentence->localWord("mood") && (charId() == 7 || charId() == 5)) { + addResponse(getDialogueId(201021)); + applyFlag = true; + stateFlag = false; + } + break; + + case 74: + if (sentence->_field2C == 6) { + addResponse(getDialogueId(201022)); + applyFlag = true; + stateFlag = false; + } + break; + + case 75: + if (sentence->_field2C == 3) { + if (sentence->localWord("that") || sentence->localWord("worb")) { + addResponse(getDialogueId(201802)); + applyFlag = true; + } + } + break; + + case 76: + if (sentence->_field2C == 2 && (sentence->localWord("that") || sentence->localWord("gat"))) { + addResponse(getDialogueId(201034)); + applyFlag = true; + stateFlag = false; + } + break; + + case 77: + if (sentence->_field2C == 4 || sentence->_field2C == 3) { + if (sentence->localWord("that") || sentence->localWord("blerontis")) { + addResponse(getDialogueId(201035)); + applyFlag = true; + } + } + break; + + case 78: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(201034)); + applyFlag = true; + stateFlag = false; + } else if (sentence->_field2C == 11) { + addResponse(getDialogueId(201040)); + applyFlag = true; + } else if ((sentence->localWord("not") && sentence->localWord("remember")) + || sentence->localWord("forgot")) { + addResponse(getDialogueId(201041)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why")) { + addResponse(getDialogueId(201042)); + applyFlag = true; + stateFlag = false; + } + break; + + case 79: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(201052)); + CTrueTalkManager::triggerAction(14, 0); + applyFlag = true; + stateFlag = false; + } else if (sentence->_field2C == 12) { + addResponse(getDialogueId(202119)); + addResponse(getDialogueId(200256)); + applyFlag = true; + } + break; + + case 80: + if ((!sentence->localWord("what") && sentence->localWord("how")) + || sentence->localWord("about") + || sentence->localWord("you")) { + if (sentence->_field2C != 3 && sentence->_field2C != 4 && sentence->_field2C != 7) { + addResponse(getDialogueId(201694)); + applyFlag = true; + stateFlag = false; + } + } else { + addResponse(getDialogueId(201135)); + applyFlag = true; + } + break; + + case 81: + if ((!sentence->localWord("what") && !sentence->localWord("how")) + || !sentence->localWord("about") + || !sentence->localWord("you")) { + if (!sentence->localWord("and") || !sentence->localWord("yourself")) + break; + } + addResponse(getDialogueId(201135)); + applyFlag = true; + break; + + case 82: + if ((sentence->_field2C == 3 && sentence->localWord("mean")) + || sentence->localWord("surf") + || (sentence->localWord("what") && sentence->localWord("talk") + && sentence->localWord("about"))) { + addResponse(getDialogueId(201694)); + applyFlag = true; + stateFlag = false; + } + break; + + case 83: + if (sentence->_field2C != 3 && sentence->_field2C != 4 && sentence->_field2C != 7) { + addResponse(getDialogueId(201083)); + applyFlag = true; + } + break; + + case 84: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(202119)); + + switch (getValue(1)) { + case 1: + addResponse(getDialogueId(202024)); + applyFlag = true; + break; + case 2: + addResponse(getDialogueId(201812)); + applyFlag = true; + stateFlag = false; + break; + default: + break; + } + } else if (sentence->_field2C == 11) { + addResponse(getDialogueId(201060)); + addResponse(getDialogueId(201079)); + applyFlag = true; + stateFlag = false; + } + break; + + case 85: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(201814)); + applyFlag = true; + } + if (sentence->_field2C == 12) { + addResponse(getDialogueId(201813)); + applyFlag = true; + } + break; + + case 86: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(202109)); + applyFlag = true; + } + if (sentence->_field2C == 12) { + addResponse(getDialogueId(202108)); + applyFlag = true; + } + break; + + case 87: + if (better(sentence, 201993, 200720)) { + applyFlag = true; + } + break; + + case 88: + if (sentence->_field2C == 6 || sentence->contains("upside down")) { + addResponse(getDialogueId(202142)); + applyFlag = true; + } + break; + + case 89: + if (sentence->_field2C == 2) { + addResponse(getDialogueId(200739)); + applyFlag = true; + stateFlag = false; + } + break; + + case 90: + if (sentence->contains("like") && (sentence->contains("slug") || sentence->contains("snail"))) { + addResponse(getDialogueId(201029)); + applyFlag = true; + stateFlag = false; + } else if (sentence->contains("slime") || sentence->localWord("what")) { + addResponse(getDialogueId(201220)); + applyFlag = true; + stateFlag = false; + } + + default: + break; + } + + if (applyFlag) + applyResponse(); + if (stateFlag) { + setState(0); + CTrueTalkManager::setFlags(23, 0); + } + + return applyFlag ? 2 : 1; +} + +bool BellbotScript::better(const TTsentence *sentence, uint id1, uint id2) { + if (sentence->contains("good") || sentence->localWord("better")) { + addResponse(getDialogueId(id1)); + } else if (sentence->localWord("bad")) { + addResponse(getDialogueId(id2)); + } else { + return false; + } + + return true; +} + +bool BellbotScript::randomResponse0(const TTroomScript *roomScript, uint id) { + bool dr0 = getDialRegion(0) == 1; + uint newId = getValue(1); + + if (getValue(25) == 0) { + CTrueTalkManager::setFlags(25, 1); + if (getValue(1) > 2) { + addResponse(getDialogueId(202043)); + applyResponse(); + return true; + } + } + + bool result = dr0 ? randomResponse1(roomScript, newId) : + randomResponse2(roomScript, newId); + if (result) + CTrueTalkManager::triggerAction(1, 0); + + return true; +} + +bool BellbotScript::randomResponse1(const TTroomScript *roomScript, uint id) { + if (getRandomNumber(100) < 10) { + addResponse(getDialogueId(201978)); + applyResponse(); + } else { + if (getRandomNumber(100) < 50) + addResponse(getDialogueId(202259)); + + randomResponse3(roomScript, id); + applyResponse(); + } + + return false; +} + +bool BellbotScript::randomResponse2(const TTroomScript *roomScript, uint id) { + if (getRandomNumber(100) < 5) { + addResponse(getDialogueId(202262)); + applyResponse(); + } else { + if (getRandomNumber(100) < 40) + addResponse(getDialogueId(202258)); + + randomResponse4(roomScript, id); + applyResponse(); + } + + return false; +} + +void BellbotScript::randomResponse3(const TTroomScript *roomScript, uint id) { + bool result = false; + if (roomScript && getRandomNumber(100) < 50) + result = addRoomDescription(roomScript); + + if (result) + return; + if (getRandomNumber(100) >= 50) { + addResponse(getDialogueId(202262)); + return; + } + + if (id <= 2) { + if (getRandomNumber(100) < 50) { + addResponse(getDialogueId(202266)); + return; + } else if (id == 2) { + addResponse(getDialogueId(202264)); + return; + } + } + + addResponse(getDialogueId(id == 1 ? 202265 : 202263)); +} + +void BellbotScript::randomResponse4(const TTroomScript *roomScript, uint id) { + if (getRandomNumber(100) < 4 && id <= 2) { + addResponse(getDialogueId(202268)); + } else { + addResponse(getDialogueId(202267)); + } +} + +int BellbotScript::checkCommonSentences(const TTroomScript *roomScript, const TTsentence *sentence) { + if (!roomScript || !sentence) + return 1; + + uint val1 = getValue(1); + for (uint idx = 0; idx < _phrases.size(); ++idx) { + TTcommonPhrase &cp = _phrases[idx]; + + if (cp._roomNum != 0 && cp._roomNum != roomScript->_scriptId) + continue; + if (cp._val1 != 0 && cp._val1 != val1 && (cp._val1 == 3 || val1 != 4)) + continue; + if (!sentence->contains(cp._str.c_str())) + continue; + + addResponse(getDialogueId(cp._dialogueId)); + applyResponse(); + return 2; + } + + return 0; +} + +bool BellbotScript::checkCommonWords(const TTroomScript *roomScript, const TTsentence *sentence) { + if (!roomScript || !sentence) + return 0; + CTrueTalkManager::setFlags(23, 0); + if (sentence->_field2C != 4) + return 0; + + if (sentence->localWord("garage")) { + addResponse(getDialogueId(200874)); + } else if (sentence->localWord("parrotfoodshop")) { + addResponse(getDialogueId(200821)); + } else if (sentence->localWord("sgt") && sentence->localWord("restaurant")) { + addResponse(getDialogueId(200857)); + } else if (sentence->localWord("firstclass") && sentence->localWord("restaurant")) { + addResponse(getDialogueId(200839)); + } else if (sentence->localWord("restaurant")) { + addResponse(getDialogueId(getValue(1) == 1 ? 200839 : 200857)); + } else if (getValue(1) == 1 && sentence->localWord("canal") && sentence->localWord("firstclass")) { + addResponse(getDialogueId(200846)); + } else if (getValue(1) == 2 && sentence->localWord("canal") && sentence->localWord("secondclass")) { + addResponse(getDialogueId(200847)); + } else if (sentence->localWord("canal")) { + addResponse(getDialogueId(getValue(1) == 1 ? 200846 : 200847)); + } else if (sentence->localWord("firstclass") && + (sentence->localWord("stateroom") || sentence->localWord("room"))) { + addResponse(getDialogueId(getValue(1) == 1 ? 200840 : 200306)); + } else if (sentence->localWord("secondclass") && sentence->localWord("stateroom") && sentence->localWord("room")) { + addResponse(getDialogueId(getValue(1) < 3 ? 202231 : 200306)); + } else if (sentence->localWord("stateroom") || sentence->contains("my room")) { + addResponse(getDialogueId(202231)); + } else if (sentence->localWord("firstclass")) { + addResponse(getDialogueId(200840)); + } else if (sentence->localWord("secondclass")) { + addResponse(getDialogueId(200841)); + } else if (sentence->localWord("thirdclass")) { + addResponse(getDialogueId(202231)); + } else if (sentence->localWord("arboretum")) { + addResponse(getDialogueId(200842)); + } else if (sentence->localWord("bar")) { + addResponse(getDialogueId(200843)); + } else if (sentence->localWord("bottomofwell")) { + addResponse(getDialogueId(200860)); + } else if (sentence->localWord("topwell") || sentence->localWord("well")) { + addResponse(getDialogueId(200861)); + } else if (sentence->localWord("bridge")) { + addResponse(getDialogueId(202213)); + } else if (sentence->localWord("creatorroom")) { + addResponse(getDialogueId(200848)); + } else if (sentence->localWord("servicelift")) { + addResponse(getDialogueId(200855)); + } else if (sentence->localWord("lift")) { + addResponse(getDialogueId(202256)); + } else if (sentence->localWord("bilgeroom")) { + addResponse(getDialogueId(202255)); + } else if (sentence->localWord("musicroom")) { + addResponse(getDialogueId(200851)); + } else if (sentence->localWord("parrotlobby")) { + addResponse(getDialogueId(200852)); + } else if (sentence->localWord("parrot") && + (sentence->localWord("room") || sentence->localWord("lobby"))) { + addResponse(getDialogueId(200852)); + } else if (sentence->localWord("promenade")) { + addResponse(getDialogueId(200853)); + } else if (sentence->localWord("sculpture") || sentence->localWord("sculptureroom") + || sentence->localWord("statue")) { + addResponse(getDialogueId(200854)); + } else if (sentence->localWord("lounge")) { + addResponse(getDialogueId(200856)); + } else if (sentence->localWord("titania")) { + if (sentence->localWord("room")) { + addResponse(getDialogueId(200859)); + } else if (sentence->localWord("nose")) { + addResponse(getDialogueId(200703)); + } else if (sentence->localWord("mouth")) { + addResponse(getDialogueId(200702)); + } else if (sentence->localWord("eyes")) { + addResponse(getDialogueId(200701)); + } else if (sentence->localWord("ear")) { + addResponse(getDialogueId(200698)); + } else if (sentence->localWord("brain")) { + addResponse(getDialogueId(200693)); + } else { + addResponse(getDialogueId(200686)); + } + } else if (sentence->localWord("embarklobby") + || sentence->localWord("lobby")) { + addResponse(getDialogueId(200850)); + } else if (sentence->localWord("pellerator")) { + addResponse(getDialogueId(200862)); + } else if (sentence->localWord("servicelift") + || (sentence->localWord("service") && sentence->localWord("elevator"))) { + addResponse(getDialogueId(200855)); + } else if (sentence->localWord("elevator")) { + addResponse(getDialogueId(202256)); + } else if (sentence->localWord("now")) { + addResponse(getDialogueId(200788)); + } else if (sentence->localWord("room")) { + addResponse(getDialogueId(200311)); + } else { + return false; + } + + return true; +} + +uint BellbotScript::getRoomDialogueId(const TTroomScript *roomScript) { + if (!roomScript) + return 0; + + for (int idx = 0; ROOM_DIALOGUE_IDS[idx]._roomNum; ++idx) { + if (ROOM_DIALOGUE_IDS[idx]._roomNum == roomScript->_scriptId) + return ROOM_DIALOGUE_IDS[idx]._dialogueId; + } + + return 0; +} + +bool BellbotScript::addRoomDescription(const TTroomScript *roomScript) { + if (!roomScript) + return false; + + switch (roomScript->_scriptId) { + case 101: + addResponse(getDialogueId(getValue(2) == 1 ? 20185 : 201832)); + break; + case 107: + if (_room107First) { + addResponse(getDialogueId(202162)); + } else { + addResponse(getDialogueId(202162)); + _room107First = true; + } + break; + case 108: + addResponse(getDialogueId(201844)); + break; + case 109: + addResponse(getDialogueId(200303)); + break; + case 110: + addResponse(getDialogueId(202257)); + break; + case 111: + addResponse(getDialogueId(202056)); + break; + case 112: + addResponse(getDialogueId(201828)); + break; + case 113: + addResponse(getDialogueId(201859)); + break; + case 114: + addResponse(getDialogueId(202052)); + break; + case 115: + addResponse(getDialogueId(202004)); + break; + case 116: + addResponse(getDialogueId(202092)); + break; + case 117: + addResponse(getDialogueId(202027)); + break; + case 124: + addResponse(getDialogueId(202110)); + break; + case 125: + addResponse(getDialogueId(202103)); + break; + case 126: + addResponse(getDialogueId(202116)); + break; + case 127: + addResponse(getDialogueId(202111)); + break; + case 128: + addResponse(getDialogueId(201815)); + break; + case 129: + addResponse(getDialogueId(201816)); + break; + case 131: + addResponse(getDialogueId(201930)); + break; + case 132: + addResponse(getDialogueId(201924)); + break; + default: + return false; + } + + return true; +} + + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/bellbot_script.h b/engines/titanic/true_talk/bellbot_script.h new file mode 100644 index 0000000000..3080b56902 --- /dev/null +++ b/engines/titanic/true_talk/bellbot_script.h @@ -0,0 +1,129 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_BELLBOT_SCRIPT_H +#define TITANIC_BELLBOT_SCRIPT_H + +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class BellbotScript : public TTnpcScript { +private: + static uint _oldId; + TTmapEntryArray _states; + TTmapEntryArray _preResponses; + TTsentenceEntries _sentences[20]; + TTcommonPhraseArray _phrases; + int _array[150]; + int _field2D0; + int _field2D4; + int _field2D8; + int _field2DC; + bool _room107First; +private: + /** + * Setup sentence data + */ + void setupSentences(); + + /** + * Add the current location to the response + */ + int addLocation(); + + /** + * Get a dialogue Id based on the state + */ + int getStateDialogueId() const; + + /** + * Sets the state value 25 based on the passed Id + */ + void setValue23(uint id); + + /** + * Does preprocessing for the sentence + */ + int preprocess(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Checks for good, better, or bad in the sentence + */ + bool better(const TTsentence *sentence, uint id1, uint id2); + + bool randomResponse0(const TTroomScript *roomScript, uint id); + bool randomResponse1(const TTroomScript *roomScript, uint id); + bool randomResponse2(const TTroomScript *roomScript, uint id); + void randomResponse3(const TTroomScript *roomScript, uint id); + void randomResponse4(const TTroomScript *roomScript, uint id); + + int checkCommonSentences(const TTroomScript *roomScript, const TTsentence *sentence); + bool checkCommonWords(const TTroomScript *roomScript, const TTsentence *sentence); + + uint getRoomDialogueId(const TTroomScript *roomScript); + + /** + * Adds a description of the room to the conversation response + */ + bool addRoomDescription(const TTroomScript *roomScript); +public: + BellbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + virtual int handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + + /** + * Process a sentence fragment entry + */ + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Handles a randomzied response + */ + virtual bool randomResponse(uint index); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_BELLBOT_SCRIPT_H */ diff --git a/engines/titanic/true_talk/deskbot_script.cpp b/engines/titanic/true_talk/deskbot_script.cpp new file mode 100644 index 0000000000..f3a997e218 --- /dev/null +++ b/engines/titanic/true_talk/deskbot_script.cpp @@ -0,0 +1,1502 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/deskbot_script.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +int DeskbotScript::_oldId; + +DeskbotScript::DeskbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, -1, -1, -1, 0) { + CTrueTalkManager::setFlags(18, 0); + CTrueTalkManager::setFlags(19, 0); + CTrueTalkManager::setFlags(20, 0); + CTrueTalkManager::setFlags(21, 0); + CTrueTalkManager::setFlags(22, 0); + + setupDials(0, 0, 0); + _data[0] = 100; + if (_currentDialNum == 1) + _currentDialNum = 0; + + loadRanges("Ranges/Deskbot"); + loadResponses("Responses/Deskbot", 4); + setupSentences(); + _tagMappings.load("TagMap/Deskbot"); + _words.load("Words/Deskbot"); + _quotes.load("Quotes/Deskbot"); + _states.load("States/Deskbot"); +} + +void DeskbotScript::setupSentences() { + _mappings.load("Mappings/Deskbot", 4); + _entries.load("Sentences/Deskbot"); + _entries2.load("Sentences/Deskbot/2"); + _entries3.load("Sentences/Deskbot/3"); + _dialValues[0] = _dialValues[1] = 0; + _field68 = 0; + _entryCount = 0; +} + +int DeskbotScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + if (roomScript->_scriptId != 110) + return 2; + + bool flag20 = getValue(20) != 0; + CTrueTalkManager::setFlags(20, 0); + checkItems(nullptr, nullptr); + + if (preprocess(roomScript, sentence) != 1) + return 1; + + CTrueTalkManager::setFlags(17, 0); + setState(0); + updateCurrentDial(false); + + if (getValue(1) == 3) { + if (sentence->localWord("competition") || sentence->contains("competition") + || sentence->localWord("won") || sentence->contains("won") + || sentence->localWord("winning") || sentence->contains("winning") + || sentence->localWord("winner") || sentence->contains("winner") + || sentence->contains("35279") || sentence->contains("3 5 2 7 9") + ) { + addResponse(getDialogueId(41773)); + applyResponse(); + return 2; + } else if (sentence->localWord("magazine") || sentence->contains("magazine")) { + addResponse(getDialogueId(41771)); + applyResponse(); + return 2; + } else if (sentence->localWord("upgrade") || sentence->contains("upgrade")) { + if (CTrueTalkManager::_currentNPC) { + CGameObject *obj; + if (CTrueTalkManager::_currentNPC->find("Magazine", &obj, FIND_PET)) { + addResponse(getDialogueId(41773)); + applyResponse(); + return 2; + } + } + } + } + + if (processEntries(&_entries, _entryCount, roomScript, sentence) != 2 + && processEntries(&_entries2, 0, roomScript, sentence) != 2) { + if (sentence->localWord("sauce") || sentence->localWord("pureed")) { + addResponse(getDialogueId(240398)); + applyResponse(); + } else if (sentence->contains("cherries")) { + addResponse(getDialogueId(240358)); + applyResponse(); + } else if (sentence->contains("42")) { + addResponse(getDialogueId(240453)); + applyResponse(); + } else if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(241778)); + applyResponse(); + } else { + if (sentence->contains("98129812")) + setDialRegion(1, 1); + + if (!defaultProcess(roomScript, sentence) + && processEntries(&_entries3, 0, roomScript, sentence) != 2 + && processEntries(_defaultEntries, 0, roomScript, sentence) != 2) { + if (flag20) + CTrueTalkManager::setFlags(20, 1); + addResponse(getDialogueId(240569)); + applyResponse(); + } + } + } + + return 2; +} + +ScriptChangedResult DeskbotScript::scriptChanged(const TTroomScript *roomScript, uint id) { + switch (id) { + case 3: + case 100: + case 108: + CTrueTalkManager::setFlags(21, getValue(21) + 1); + addResponse(getDialogueId(getValue(22) ? 240577 : 241261)); + applyResponse(); + break; + + case 109: + addResponse(getDialogueId(241627)); + applyResponse(); + break; + + case 140: + if (getValue(1) == 3) + addAssignedRoomDialogue3(); + break; + + case 148: + CTrueTalkManager::setFlags(3, 1); + break; + + case 150: + CTrueTalkManager::setFlags(2, 1); + break; + } + + return SCR_2; +} + +int DeskbotScript::handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder) { + switch (tagId) { + case MKTAG('A', 'D', 'V', 'T'): + case MKTAG('A', 'R', 'T', 'I'): + case MKTAG('A', 'R', 'T', 'Y'): + case MKTAG('B', 'R', 'N', 'D'): + case MKTAG('C', 'O', 'M', 'D'): + case MKTAG('D', 'N', 'C', 'E'): + case MKTAG('H', 'B', 'B', 'Y'): + case MKTAG('L', 'I', 'T', 'R'): + case MKTAG('M', 'A', 'G', 'S'): + case MKTAG('M', 'C', 'P', 'Y'): + case MKTAG('M', 'I', 'N', 'S'): + case MKTAG('M', 'U', 'S', 'I'): + case MKTAG('N', 'I', 'K', 'E'): + case MKTAG('S', 'F', 'S', 'F'): + case MKTAG('S', 'O', 'A', 'P'): + case MKTAG('S', 'O', 'N', 'G'): + case MKTAG('S', 'P', 'R', 'T'): + case MKTAG('T', 'E', 'A', 'M'): + case MKTAG('T', 'V', 'S', 'H'): + tagId = MKTAG('E', 'N', 'T', 'N'); + break; + case MKTAG('A', 'C', 'T', 'R'): + case MKTAG('A', 'C', 'T', 'S'): + case MKTAG('A', 'U', 'T', 'H'): + case MKTAG('B', 'A', 'R', 'K'): + case MKTAG('B', 'A', 'R', 'U'): + case MKTAG('B', 'L', 'F', '1'): + case MKTAG('B', 'L', 'F', '2'): + case MKTAG('B', 'L', 'P', '1'): + case MKTAG('B', 'L', 'P', '2'): + case MKTAG('B', 'L', 'P', '3'): + case MKTAG('B', 'L', 'P', '4'): + case MKTAG('B', 'L', 'R', '1'): + case MKTAG('B', 'L', 'R', '2'): + case MKTAG('B', 'L', 'T', '1'): + case MKTAG('B', 'L', 'T', '2'): + case MKTAG('B', 'L', 'T', '3'): + case MKTAG('B', 'L', 'T', '4'): + case MKTAG('B', 'L', 'T', '5'): + case MKTAG('B', 'O', 'Y', 'S'): + case MKTAG('C', 'O', 'P', 'S'): + case MKTAG('D', 'C', 'T', 'R'): + case MKTAG('F', 'A', 'M', 'E'): + case MKTAG('F', 'A', 'S', 'H'): + case MKTAG('G', 'I', 'R', 'L'): + case MKTAG('H', 'E', 'R', 'O'): + case MKTAG('H', 'O', 'S', 'T'): + case MKTAG('K', 'N', 'O', 'B'): + case MKTAG('N', 'H', 'R', 'O'): + case MKTAG('R', 'A', 'C', 'E'): + case MKTAG('S', 'C', 'I', 'T'): + case MKTAG('T', 'D', 'V', 'P'): + case MKTAG('T', 'W', 'A', 'T'): + case MKTAG('W', 'E', 'A', 'T'): + case MKTAG('W', 'W', 'E', 'B'): + tagId = MKTAG('P', 'R', 'S', 'N'); + break; + case MKTAG('C', 'H', 'S', 'E'): + case MKTAG('C', 'M', 'N', 'T'): + case MKTAG('F', 'I', 'L', 'M'): + case MKTAG('J', 'F', 'O', 'D'): + case MKTAG('L', 'I', 'Q', 'D'): + tagId = MKTAG('F', 'O', 'O', 'D'); + break; + case MKTAG('C', 'R', 'I', 'M'): + case MKTAG('C', 'S', 'P', 'Y'): + case MKTAG('D', 'R', 'U', 'G'): + tagId = MKTAG('V', 'B', 'A', 'D'); + break; + case MKTAG('E', 'A', 'R', 'T'): + case MKTAG('H', 'O', 'M', 'E'): + case MKTAG('N', 'P', 'L', 'C'): + case MKTAG('P', 'L', 'A', 'N'): + tagId = MKTAG('P', 'L', 'A', 'C'); + break; + case MKTAG('F', 'A', 'U', 'N'): + case MKTAG('F', 'I', 'S', 'H'): + case MKTAG('F', 'L', 'O', 'R'): + tagId = MKTAG('N', 'A', 'T', 'R'); + break; + case MKTAG('H', 'H', 'L', 'D'): + case MKTAG('T', 'O', 'Y', 'S'): + case MKTAG('W', 'E', 'A', 'P'): + tagId = MKTAG('M', 'A', 'C', 'H'); + break; + case MKTAG('M', 'L', 'T', 'Y'): + case MKTAG('P', 'G', 'R', 'P'): + case MKTAG('P', 'T', 'I', 'C'): + tagId = MKTAG('G', 'R', 'U', 'P'); + break; + case MKTAG('P', 'K', 'U', 'P'): + case MKTAG('S', 'E', 'X', '1'): + case MKTAG('S', 'W', 'E', 'R'): + tagId = MKTAG('R', 'U', 'D', 'E'); + break; + case MKTAG('P', 'H', 'I', 'L'): + case MKTAG('R', 'C', 'K', 'T'): + tagId = MKTAG('S', 'C', 'I', 'E'); + break; + case MKTAG('T', 'R', 'A', '2'): + case MKTAG('T', 'R', 'A', '3'): + tagId = MKTAG('T', 'R', 'A', 'V'); + break; + default: + break; + } + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); + +} + +int DeskbotScript::updateState(uint oldId, uint newId, int index) { + if (isDial1Medium() || getValue(1) < 4) + CTrueTalkManager::setFlags(22, 1); + + if (newId == 240420 || newId == 240947 || newId == 241261) { + if (getValue(22) && (newId == 240947 || newId == 241261)) + newId = getRangeValue(241184); + } + + if (newId == 240832) + setDialRegion(1, 0); + + if (oldId == 241183) { + if (getValue(1) == 2) + newId = getRangeValue(241182); + else if (getValue(1) == 1) + newId = getRangeValue(241181); + } + + if (newId == 240931 && getValue(1) <= 2) { + newId = 240924; + } else if (newId == 240924 && getValue(1) > 2) { + newId = 240931; + } + + if (newId == 240830 && getValue(1) == 1) { + newId = 240801; + } else if (newId == 240801 && getValue(1) > 1) { + newId = 240830; + } + + if (oldId >= 241217 && oldId <= 241259) { + addResponse(getDialogueId(241202)); + addResponse(getDialogueId(241200)); + newId = getRangeValue(241199); + } + + if (newId == 241354) + newId = addAssignedRoomDialogue2(); + if (newId == 241353) + newId = getStateDialogueId(); + if (newId == 240464 && getValue(1) != 1) + newId = 240462; + + if (newId == 241635 && isDial1Medium()) { + addResponse(getDialogueId(241556)); + newId = getRangeValue(241632); + } + + if (getValue(20) && (oldId == 240569 || oldId == 240576)) + newId = 240460; + if (!getValue(20)) { + if (newId != 240460) + goto exit; + CTrueTalkManager::setFlags(20, 1); + } + if (newId == 240460 && _oldId != 240569) { + CTrueTalkManager::setFlags(20, 0); + newId = 240455; + } + +exit: + _oldId = oldId; + setFlags17(newId, index); + + return newId; +} + +int DeskbotScript::preResponse(uint id) { + int newId = 0; + if (getValue(1) >= 3 && (id == 41176 || id == 41738 || id == 41413 || id == 41740)) + newId = 241601; + + if (id == 42114) + CTrueTalkManager::triggerAction(20, 0); + + return newId; +} + +uint DeskbotScript::getDialsBitset() const { + if (getDialRegion(1)) + return getDialRegion(0) ? 2 : 3; + else + return getDialRegion(0) ? 0 : 1; +} + +int DeskbotScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + uint id; + + switch (val1) { + case 1: + id = *srcIdP; + if (id == 240431 || id == 240432) { + switch (getValue(1)) { + case 1: + id = 240336; + break; + case 2: + id = addAssignedRoomDialogue(); + break; + case 3: + if (getValue(3) == 1) { + if (id == 240431) + id = 240432; + } + else { + if (id == 240432) + id = 240431; + } + default: + break; + } + + addResponse(getDialogueId(id)); + applyResponse(); + return 2; + } + break; + + case 2: + if (getValue(1) == 1) + return true; + break; + + default: + break; + } + + return 0; +} + +bool DeskbotScript::randomResponse(uint index) { + if (getValue(1) == 1 || getRandomNumber(100) > 10 || getRandomNumber(2) <= index) + return 0; + + if (getRandomNumber(100) > 95) { + deleteResponses(); + addResponse(getDialogueId(241195)); + applyResponse(); + } else { + setResponseFromArray(index, 241193); + } + + return true; +} + +bool DeskbotScript::isDial0Medium() const { + return getDialRegion(0) == 1; +} + +bool DeskbotScript::isDial0Low() const { + return getDialRegion(0) == 0; +} + +bool DeskbotScript::isDial1Medium() const { + return getDialRegion(1) == 1; +} + +bool DeskbotScript::isDial1Low() const { + return getDialRegion(1) == 0; +} + +uint DeskbotScript::addAssignedRoomDialogue() { + if (isDial1Medium()) { + addResponse(getDialogueId(240407)); + addResponse(getDialogueId(241510)); + CTrueTalkManager::setFlags(1, 1); + CTrueTalkManager::triggerAction(19, 1); + + int roomNum, floorNum, elevatorNum; + getAssignedRoom(&roomNum, &floorNum, &elevatorNum); + + addResponse(getDialogueId(241317 + roomNum)); + addResponse(getDialogueId(241271 + floorNum)); + addResponse(getDialogueId(241511)); + addResponse(getDialogueId(241313 + elevatorNum)); + + return 241512; + } else { + return 240567; + } +} + +uint DeskbotScript::addAssignedRoomDialogue2() { + addResponse(getDialogueId(241355)); + int roomNum = 0, floorNum = 0, elevatorNum = 0; + getAssignedRoom(&roomNum, &floorNum, &elevatorNum); + + addResponse(getDialogueId(241317 + roomNum)); + addResponse(getDialogueId(241271 + floorNum)); + addResponse(getDialogueId(241356)); + addResponse(getDialogueId(241313 + elevatorNum)); + + return 241357; +} + +void DeskbotScript::addAssignedRoomDialogue3() { + addResponse(getDialogueId(241513)); + addResponse(getDialogueId(241510)); + + CTrueTalkManager::setFlags(1, 2); + setDialRegion(0, 0); + setDialRegion(1, 0); + CTrueTalkManager::triggerAction(19, 2); + CTrueTalkManager::setFlags(3, 0); + + int roomNum = 1, floorNum = 1, elevatorNum = 1; + getAssignedRoom(&roomNum, &floorNum, &elevatorNum); + + addResponse(getDialogueId(241317 + roomNum)); + addResponse(getDialogueId(241271 + floorNum)); + addResponse(getDialogueId(241511)); + addResponse(getDialogueId(241313 + elevatorNum)); + addResponse(getDialogueId(241512)); + applyResponse(); +} + +uint DeskbotScript::getStateDialogueId() const { + switch (getValue(1)) { + case 1: + return 241503; + case 2: + return 241504; + default: + return 241505; + } +} + +void DeskbotScript::setFlags17(uint newId, uint index) { + int newValue = getValue(17); + + for (uint idx = 0; idx < _states.size(); ++idx) { + const TTupdateState &us = _states[idx]; + if (newId == (idx == 0 ? 0 : us._newId)) { + uint bits = us._dialBits; + + if (!bits + || (index == 1 && (bits & 1) && (bits & 4)) + || (index == 0 && (bits & 2) && (bits & 4)) + || (index == 3 && (bits & 1) && (bits & 8)) + || (index == 2 && (bits & 2) && (bits & 8))) { + newValue = us._newValue; + break; + } + } + } + + CTrueTalkManager::setFlags(17, newValue); +} + +int DeskbotScript::preprocess(const TTroomScript *roomScript, const TTsentence *sentence) { + if (!roomScript || !sentence) + return 1; + + bool stateFlag = true, applyFlag = false; + switch (getValue(17)) { + case 1: + if (sentence->_field2C != 3 && sentence->_field2C != 4 + && sentence->_field2C != 6 && sentence->_field2C != 10 + && sentence->_field2C != 2) { + addResponse(getDialogueId(240423)); + applyFlag = true; + } + break; + + case 2: + if (sentence->localWord("gobbledygook")) { + addResponse(getDialogueId(240427)); + applyFlag = true; + } + break; + + case 3: + if (sentence->_field2C == 11 || sentence->_field2C == 13 + || sentence->_field2C == 3 || sentence->localWord("upgrade")) { + addResponse(getDialogueId(240433)); + applyFlag = true; + } + break; + + case 4: + addResponse(getDialogueId(sentence->_field2C == 11 || sentence->_field2C == 13 + ? 240495 : 240494)); + applyFlag = true; + break; + + case 5: + if (isDial1Low() && getValue(1) == 4) { + if (sentence->localWord("name") || sentence->localWord("called") + || sentence->localWord("passenger")) { + addResponse(getDialogueId(240867)); + addResponse(getDialogueId(240745)); + } else { + addResponse(getDialogueId(240446)); + } + + applyFlag = true; + stateFlag = false; + } + break; + + case 6: + if (isDial1Low() && getValue(1) == 4) { + if (sentence->localWord("passenger")) { + addResponse(getDialogueId(240449)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("home") + || sentence->localWord("destroy")) { + addResponse(getDialogueId(240574)); + stateFlag = true; + } else if (sentence->localWord("name") + || sentence->localWord("called") + || sentence->_field2C == 11) { + addResponse(getDialogueId(240448)); + stateFlag = true; + } else { + addResponse(getDialogueId(240489)); + stateFlag = true; + } + } + break; + + case 7: + if (sentence->_field2C == 11 || sentence->_field2C == 13 + || (sentence->localWord("what") && sentence->localWord("wrong")) + || sentence->localWord("clothes")) { + addResponse(getDialogueId(240489)); + applyFlag = true; + stateFlag = false; + } + break; + + case 8: + if (isDial1Low() && getValue(1) == 4) { + if (sentence->_field2C == 12 || sentence->_field2C == 13 + || sentence->contains("do not")) { + + addResponse(getDialogueId(240447)); + setDialRegion(0, 0); + setDialRegion(1, 0); + CTrueTalkManager::setFlags(1, 3); + CTrueTalkManager::triggerAction(19, 3); + CTrueTalkManager::setFlags(22, 1); + applyFlag = true; + } else if (sentence->_field2C == 11) { + addResponse(getDialogueId(240746)); + applyFlag = true; + stateFlag = false; + } else { + addResponse(getDialogueId(240448)); + applyFlag = true; + stateFlag = false; + } + } + break; + + case 9: + if (searchQuotes(roomScript, sentence)) { + if (isDial0Medium()) { + addResponse(getDialogueId(240382)); + applyFlag = true; + stateFlag = false; + } else { + addResponse(getDialogueId(240548)); + applyFlag = true; + } + } + break; + + case 10: + if (isDial1Medium() && searchQuotes(roomScript, sentence)) { + if (isDial0Medium()) { + addResponse(getDialogueId(240405)); + applyFlag = true; + stateFlag = false; + } else { + addResponse(getDialogueId(240548)); + applyFlag = true; + } + } + break; + + case 11: + if (isDial0Medium() && isDial1Medium() + && searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240403)); + applyFlag = true; + stateFlag = false; + } + break; + + case 12: + if (isDial0Medium() && isDial1Medium() + && searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240548)); + applyFlag = true; + stateFlag = false; + } + break; + + case 13: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240348)); + applyFlag = true; + stateFlag = false; + } + break; + + case 14: + if (isDial1Medium()) { + addResponse(getDialogueId(240568)); + applyFlag = true; + stateFlag = false; + } + break; + + case 15: + if (sentence->localWord("magazine")) { + addAssignedRoomDialogue3(); + stateFlag = true; + } + break; + + case 17: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240401)); + applyFlag = true; + stateFlag = false; + } + break; + + case 18: + if (!isDial0Low() || !isDial1Low()) { + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240402)); + applyFlag = true; + stateFlag = false; + } + } + break; + + case 19: + if (!isDial0Low() && searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240403)); + applyFlag = true; + stateFlag = false; + } + break; + + case 20: + if (!isDial1Medium() && searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240548)); + applyFlag = true; + } + break; + + case 21: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240382)); + applyFlag = true; + stateFlag = false; + } + break; + + case 22: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240383)); + applyFlag = true; + stateFlag = false; + } + break; + + case 23: + if (isDial0Medium() && searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240384)); + applyFlag = true; + stateFlag = false; + } + break; + + case 24: + setDialRegion(0, 0); + + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240548)); + applyFlag = true; + } + break; + + case 25: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240349)); + applyFlag = true; + stateFlag = false; + } + break; + + case 26: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240350)); + applyFlag = true; + stateFlag = false; + } + break; + + case 27: + case 30: + case 33: + case 36: + case 40: + case 43: + case 46: + case 50: + case 55: + case 58: + case 61: + case 68: + case 73: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240548)); + applyFlag = true; + } + break; + + case 28: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240373)); + applyFlag = true; + stateFlag = false; + } + break; + + case 29: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240374)); + applyFlag = true; + stateFlag = false; + } + break; + + case 31: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240346)); + applyFlag = true; + stateFlag = false; + } + break; + + case 32: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240347)); + applyFlag = true; + stateFlag = false; + } + break; + + case 34: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240376)); + applyFlag = true; + stateFlag = false; + } + break; + + case 35: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240377)); + applyFlag = true; + stateFlag = false; + } + break; + + case 37: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240369)); + applyFlag = true; + stateFlag = false; + } + break; + + case 38: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240370)); + applyFlag = true; + stateFlag = false; + } + break; + + case 39: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240371)); + applyFlag = true; + stateFlag = false; + } + break; + + case 41: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240352)); + applyFlag = true; + stateFlag = false; + } + break; + + case 42: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240353)); + applyFlag = true; + stateFlag = false; + } + break; + + case 44: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240389)); + applyFlag = true; + stateFlag = false; + } + break; + + case 45: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240390)); + applyFlag = true; + stateFlag = false; + } + break; + + case 47: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240395)); + applyFlag = true; + stateFlag = false; + } + break; + + case 48: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240396)); + applyFlag = true; + stateFlag = false; + } + break; + + case 49: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240397)); + applyFlag = true; + stateFlag = false; + } + break; + + case 51: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240363)); + applyFlag = true; + stateFlag = false; + } + break; + + case 52: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240364)); + applyFlag = true; + stateFlag = false; + } + break; + + case 53: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240365)); + applyFlag = true; + stateFlag = false; + } + break; + + case 54: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240366)); + applyFlag = true; + stateFlag = false; + } + break; + + case 56: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240392)); + applyFlag = true; + stateFlag = false; + } + break; + + case 57: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240393)); + applyFlag = true; + stateFlag = false; + } + break; + + case 59: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240386)); + applyFlag = true; + stateFlag = false; + } + break; + + case 60: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240387)); + applyFlag = true; + stateFlag = false; + } + break; + + case 62: + if (isDial1Medium() && getValue(1) == 1) { + if (isDial0Medium()) { + if (sentence->localWord("down")) { + addResponse(getDialogueId(240413)); + applyFlag = true; + } + } else if (sentence->contains("left") || sentence->contains("right")) { + addResponse(getDialogueId(240415)); + CTrueTalkManager::triggerAction(sentence->localWord("down") ? 22 : 23, 0); + } else { + addResponse(getDialogueId(240414)); + applyFlag = true; + } + } + break; + + case 63: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240836)); + applyFlag = true; + stateFlag = false; + } + break; + + case 64: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240837)); + applyFlag = true; + stateFlag = false; + } + break; + + case 65: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240838)); + applyFlag = true; + stateFlag = false; + } + break; + + case 66: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240839)); + applyFlag = true; + stateFlag = false; + } + break; + + case 67: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(240840)); + applyFlag = true; + stateFlag = false; + } + break; + + case 69: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(241104)); + applyFlag = true; + stateFlag = false; + } + break; + + case 70: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(241105)); + applyFlag = true; + stateFlag = false; + } + break; + + case 71: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(241106)); + applyFlag = true; + stateFlag = false; + } + break; + + case 72: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(241107)); + applyFlag = true; + stateFlag = false; + } + break; + + case 74: + case 75: + if (sentence->_field2C == 24) { + addResponse(getDialogueId(240972)); + applyFlag = true; + } else if (sentence->localWord("good") || sentence->localWord("yes") + || sentence->localWord("well") || sentence->localWord("ill") + || sentence->localWord("sad")) { + addResponse(getDialogueId(240805)); + applyFlag = true; + } + break; + + case 76: + if (sentence->_field2C == 6) { + addResponse(getDialogueId(240767)); + applyFlag = true; + stateFlag = false; + } + break; + + case 77: + if (sentence->_field2C == 3) { + addResponse(getDialogueId(241109)); + applyFlag = true; + stateFlag = false; + } + + case 78: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(241262)); + } else if (sentence->_field2C == 12 || sentence->contains("do not")) { + setDialRegion(0, 0); + setDialRegion(1, 0); + addResponse(getDialogueId(241268)); + add241716(); + } else { + addResponse(getDialogueId(240745)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 79: + switch (checkCommonWords(sentence)) { + case 1: + addResponse(getDialogueId(241263)); + break; + case 2: + addResponse(getDialogueId(241266)); + break; + case 3: + addAssignedRoom(); + setState(0); + CTrueTalkManager::setFlags(17, 0); + return 2; + default: + addResponse(getDialogueId(241267)); + break; + } + + add241716(); + applyFlag = true; + stateFlag = false; + break; + + case 81: + addResponse(getDialogueId(sentence->_field2C == 12 ? 240602 : 241337)); + applyResponse(); + setState(0); + CTrueTalkManager::setFlags(17, 0); + return 2; + + case 82: + if (sentence->_field2C == 2) { + addResponse(getDialogueId(241339)); + applyFlag = true; + } + break; + + case 83: + if ((isDial1Medium() && isDial0Low()) || + (isDial1Low() && isDial0Medium())) { + if (sentence->localWord("yes") || sentence->localWord("but")) { + if (sentence->localWord("will") || sentence->localWord("do")) { + addResponse(getDialogueId(241366)); + applyFlag = true; + } + } + } + break; + + case 84: + if (sentence->_field2C == 12 || sentence->contains("vegetarian") + || sentence->contains("vegitarian")) { + addResponse(getDialogueId(241718)); + addResponse(getDialogueId(241709)); + applyFlag = true; + stateFlag = false; + } else if (sentence->contains("continental") + || sentence->contains("full") + || sentence->contains("porky") + || sentence->contains("the 1") + || sentence->contains("the 2") + || sentence->contains("former") + || sentence->contains("latter")) { + addResponse(getDialogueId(241717)); + addResponse(getDialogueId(241709)); + applyFlag = true; + stateFlag = false; + } else { + if (sentence2C(sentence)) + addResponse(getDialogueId(241707)); + addResponse(getDialogueId(241719)); + applyFlag = true; + stateFlag = false; + } + break; + + case 85: + if (sentence->_field2C == 12 || sentence->contains("bugle") + || sentence->contains("buggle") || sentence->contains("trumpet") + || sentence->contains("saxophone") || sentence->contains("kazoo") + || sentence->contains("blerontin 1") || sentence->contains("the 1") + || sentence->contains("the 2") || sentence->contains("the 3") + || sentence->contains("the 4") || sentence->contains("all of them") + || sentence->contains("the lot")) { + addResponse(getDialogueId(241710)); + addResponse(getDialogueId(241713)); + } else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241707)); + + addResponse(getDialogueId(241711)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 86: + if (sentence->_field2C == 12 || sentence->_field2C == 11 || sentence->contains("view")) { + addResponse(getDialogueId(241714)); + addResponse(getDialogueId(241699)); + } else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241707)); + + if (getRandomNumber(100) < 50) { + addResponse(getDialogueId(241715)); + } else { + addResponse(getDialogueId(241712)); + addResponse(getDialogueId(241713)); + } + + } + + applyFlag = true; + stateFlag = false; + break; + + case 87: + if (sentence->contains("corner") || sentence->contains("on the end") + || sentence->contains("balcony") || sentence->contains("neither") + || sentence->contains("the 1") || sentence->contains("the 2") + || sentence->contains("former") || sentence->contains("latter") + || sentence->contains("either")) { + addResponse(getDialogueId(241700)); + addResponse(getDialogueId(241687)); + } else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241707)); + + addResponse(getDialogueId(241701)); + addResponse(getDialogueId(241699)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 88: + if (sentence->contains("imperial") || sentence->contains("the 1")) { + addResponse(getDialogueId(241700)); + addResponse(getDialogueId(241739)); + } else if (sentence->contains("royal") || sentence->contains("the 2")) { + addResponse(getDialogueId(241690)); + } else if (sentence->contains("despotic") || sentence->contains("the last") + || sentence->contains("latter")) { + addResponse(getDialogueId(241688)); + } else if (sentence->contains("president") || sentence->contains("presidential") + || sentence->contains("the 3")) { + addResponse(getDialogueId(241689)); + } else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241707)); + + addResponse(getDialogueId(241692)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 89: + if (sentence->contains("king")) { + addResponse(getDialogueId(241691)); + } else if (sentence->contains("queen") || sentence->contains("prince") + || sentence->contains("princess") || sentence->contains("small") + || sentence->contains("the 1") || sentence->contains("the 2") + || sentence->contains("the 3") || sentence->contains("the 4") + || sentence->contains("big") || sentence->contains("large")) { + addResponse(getDialogueId(241700)); + addResponse(getDialogueId(241739)); + } else { + if (getRandomNumber(100) < 100 && sentence2C(sentence)) + addResponse(getDialogueId(241707)); + + addResponse(getDialogueId(241690)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 90: + if (sentence->contains("constitutional") || sentence->contains("const") + || sentence->contains("absolute") || sentence->contains("small") + || sentence->contains("the 1") || sentence->contains("the 2") + || sentence->contains("big") || sentence->contains("large")) { + addResponse(getDialogueId(241700)); + addResponse(getDialogueId(241739)); + } else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241708)); + + addResponse(getDialogueId(241691)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 91: + if (sentence->contains("benev") || sentence->contains("dict") + || sentence->contains("small") || sentence->contains("the 1") + || sentence->contains("the 2") || sentence->contains("big") + || sentence->contains("large") || sentence->contains("former") + || sentence->contains("latter")) { + addResponse(getDialogueId(241700)); + addResponse(getDialogueId(241739)); + } else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241708)); + + addResponse(getDialogueId(241688)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 92: + case 93: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(241077)); + addResponse(getDialogueId(241706)); + } else if (sentence->_field2C == 12) { + addAssignedRoom(); + setState(0); + CTrueTalkManager::setFlags(17, 0); + return 2; + } else if (g_vm->_trueTalkManager->_quotes.find(sentence->_normalizedLine.c_str()) + == MKTAG('F', 'I', 'S', 'H')) { + addResponse(getDialogueId(240877)); + addResponse(getDialogueId(241706)); + }else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241707)); + + addResponse(getDialogueId(241705)); + if (getRandomNumber(100) < 80) + addResponse(getDialogueId(241739)); + } + + applyFlag = true; + stateFlag = false; + break; + + case 94: + if (sentence->contains("seperate") || sentence->contains("separate") + || sentence->contains("detached") || sentence->contains("outside") + || sentence->contains("onsweet") || sentence->contains("ensuite") + || sentence->contains("suite") || sentence->contains("next door") + || sentence->contains("the 1") || sentence->contains("the 2") + || sentence->contains("former") || sentence->contains("latter") + || sentence->contains("same room")) { + addAssignedRoom(); + setState(0); + CTrueTalkManager::setFlags(17, 0); + return 2; + } else { + if (getRandomNumber(100) < 80 && sentence2C(sentence)) + addResponse(getDialogueId(241707)); + addResponse(getDialogueId(241706)); + applyFlag = true; + stateFlag = false; + } + break; + + case 95: + if (isDial1Medium()) { + if ((sentence->localWord("i") && sentence->localWord("am")) + || sentence->localWord("me")) { + addResponse(getDialogueId(240632)); + applyFlag = true; + stateFlag = false; + } + } + break; + + case 96: + if (sentence->_field2C == 2) { + addResponse(getDialogueId(241350)); + applyFlag = true; + stateFlag = false; + } + break; + + case 97: + if (searchQuotes(roomScript, sentence)) { + addResponse(getDialogueId(241351)); + applyFlag = true; + stateFlag = false; + } + break; + + default: + break; + } + + if (applyFlag) + applyResponse(); + if (stateFlag) { + setState(0); + CTrueTalkManager::setFlags(17, 0); + } + + return applyFlag ? 2 : 1; +} + +int DeskbotScript::searchQuotes(const TTroomScript *roomScript, const TTsentence *sentence) { + TTtreeResult treeResult; + return g_vm->_trueTalkManager->_quotesTree.search(sentence->_normalizedLine.c_str(), + TREE_2, &treeResult, 0, 0) != -1; +} + +int DeskbotScript::checkCommonWords(const TTsentence *sentence) { + if (sentence->contains("xyzzy")) + return 3; + + const TTquotes "es = g_vm->_trueTalkManager->_quotes; + if (quotes._loaded) { + uint tagId = quotes.find(sentence->_normalizedLine.c_str()); + if (tagId == MKTAG('F', 'U', 'L', 'N') + || tagId == MKTAG('T', 'D', 'V', 'P') + || tagId == MKTAG('H', 'E', 'R', 'O') + || sentence->contains("douglas adam")) + return 1; + else if (tagId == MKTAG('J', 'N', 'A', 'M') + || tagId == MKTAG('N', 'I', 'K', 'N') + || tagId == MKTAG('B', 'O', 'Y', 'S') + || tagId == MKTAG('G', 'I', 'R', 'L')) + return 2; + } else { + if (sentence->contains("douglas adams") + || sentence->contains("shaikh") + || sentence->contains("millican") + || sentence->contains("williams") + || sentence->contains("henkes") + || sentence->contains("kenny")) + return 1; + else if (sentence->contains("richard") + || sentence->contains("jason") + || sentence->contains("mike") + || sentence->contains("renata")) + return 2; + } + + return 0; +} + +void DeskbotScript::add241716() { + addResponse(getDialogueId(241716)); +} + +void DeskbotScript::addAssignedRoom() { + addResponse(getDialogueId(241696)); + addResponse(getDialogueId(241697)); + CTrueTalkManager::setFlags(1, 3); + CTrueTalkManager::triggerAction(19, 3); + CTrueTalkManager::setFlags(22, 1); + + int roomNum = 1, floorNum = 1, elevatorNum = 1; + getAssignedRoom(&roomNum, &floorNum, &elevatorNum); + addResponse(getDialogueId(241313 + elevatorNum)); + addResponse(getDialogueId(241271 + floorNum)); + addResponse(getDialogueId(241317 + roomNum)); + addResponse(getDialogueId(241698)); +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/deskbot_script.h b/engines/titanic/true_talk/deskbot_script.h new file mode 100644 index 0000000000..f5978553ce --- /dev/null +++ b/engines/titanic/true_talk/deskbot_script.h @@ -0,0 +1,157 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DESKBOT_SCRIPT_H +#define TITANIC_DESKBOT_SCRIPT_H + +#include "common/array.h" +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class DeskbotScript : public TTnpcScript { +private: + static int _oldId; + TTupdateStateArray _states; + TTsentenceEntries _entries2; + TTsentenceEntries _entries3; +private: + /** + * Setup sentence data + */ + void setupSentences(); + + /** + * Adds dialogue for the player's assigned room + */ + uint addAssignedRoomDialogue(); + + /** + * Adds dialogue for the player's assigned room + */ + uint addAssignedRoomDialogue2(); + + /** + * Adds dialogue for the player's assigned room + */ + void addAssignedRoomDialogue3(); + + /** + * Gets a dialogue Id based on the NPC's state + */ + uint getStateDialogueId() const; + + /** + * Sets state data in flags 17 + */ + void setFlags17(uint newId, uint index); + + /** + * Does preprocessing for the sentence + */ + int preprocess(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Scans the quotes tree + */ + int searchQuotes(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Checks for common words + */ + int checkCommonWords(const TTsentence *sentence); + + /** + * Adds response dialogue 241716 + */ + void add241716(); + + /** + * Adds a dialogue description for the player's assigned room + */ + void addAssignedRoom(); +public: + DeskbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + virtual int handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + + /** + * Returns a bitset of the first three dialgs being on or not + */ + virtual uint getDialsBitset() const; + + /** + * Process a sentence fragment entry + */ + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Handles a randomzied response + */ + virtual bool randomResponse(uint index); + + /** + * Returns true if dial 1 is the medium (1) region + */ + virtual bool isDial0Medium() const; + + /** + * Returns true if dial 0 is the low end region + */ + virtual bool isDial0Low() const; + + /** + * Returns true if dial 1 is the medium (1) region + */ + bool isDial1Medium() const; + + /** + * Returns true if dial 1 is the low end region + */ + virtual bool isDial1Low() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DESKBOT_SCRIPT_H */ diff --git a/engines/titanic/true_talk/dialogue_file.cpp b/engines/titanic/true_talk/dialogue_file.cpp new file mode 100644 index 0000000000..34eb164779 --- /dev/null +++ b/engines/titanic/true_talk/dialogue_file.cpp @@ -0,0 +1,109 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/dialogue_file.h" + +namespace Titanic { + +void DialogueIndexEntry::load(Common::SeekableReadStream &s) { + _v1 = s.readUint32LE(); + _offset = s.readUint32LE(); +} + +/*------------------------------------------------------------------------*/ + +CDialogueFile::CDialogueFile(const CString &filename, uint count) { + if (!_file.open(filename)) + error("Could not locate dialogue file - %s", filename.c_str()); + + _cache.resize(count); + + _file.readUint32LE(); // Skip over file Id + _index.resize(_file.readUint32LE()); + + // Read in the entries + for (uint idx = 0; idx < _index.size(); ++idx) + _index[idx].load(_file); +} + +CDialogueFile::~CDialogueFile() { + clear(); +} + +void CDialogueFile::clear() { + _file.close(); +} + +DialogueResource *CDialogueFile::addToCache(int index) { + if (_index.size() == 0 || index < 0 || index >= (int)_index.size() + || _cache.empty()) + return nullptr; + + // Scan cache for a free slot + uint cacheIndex = 0; + while (cacheIndex < _cache.size() && !_cache[cacheIndex]._active) + ++cacheIndex; + if (cacheIndex == _cache.size()) + return nullptr; + + DialogueIndexEntry &indexEntry = _index[index]; + DialogueResource &res = _cache[cacheIndex]; + + res._active = true; + res._offset = indexEntry._offset; + res._bytesRead = 0; + res._entryPtr = &indexEntry; + + // Figure out the size of the entry + if (index == ((int)_index.size() - 1)) { + res._size = _file.size() - indexEntry._offset; + } else { + res._size = _index[index + 1]._offset - indexEntry._offset; + } + + // Return a pointer to the loaded entry + return &res; +} + +bool CDialogueFile::closeEntry(DialogueResource *cacheEntry) { + if (!cacheEntry || !cacheEntry->_active) + return false; + + cacheEntry->_active = false; + return true; +} + +bool CDialogueFile::read(DialogueResource *cacheEntry, byte *buffer, size_t bytesToRead) { + // Sanity checks that a valid record is passed, and the size can be read + if (!cacheEntry || !cacheEntry->_active || !bytesToRead + || (cacheEntry->_bytesRead + bytesToRead) > cacheEntry->_size) + return false; + + // Move to the correct position in the file + _file.seek(cacheEntry->_offset + cacheEntry->_bytesRead); + bool result = _file.read(buffer, bytesToRead) == bytesToRead; + cacheEntry->_bytesRead += bytesToRead; + + return result; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/dialogue_file.h b/engines/titanic/true_talk/dialogue_file.h new file mode 100644 index 0000000000..19e94cf9b9 --- /dev/null +++ b/engines/titanic/true_talk/dialogue_file.h @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DIALOGUE_FILE_H +#define TITANIC_DIALOGUE_FILE_H + +#include "titanic/support/simple_file.h" +#include "titanic/support/string.h" + +namespace Titanic { + +struct DialogueIndexEntry { + uint _v1, _offset; + + DialogueIndexEntry() : _v1(0), _offset(0) {} + void load(Common::SeekableReadStream &s); +}; + +struct DialogueResource { + bool _active; + uint _offset, _bytesRead, _size; + DialogueIndexEntry *_entryPtr; + + DialogueResource() : _active(false), _offset(0), + _bytesRead(0), _size(0), _entryPtr(nullptr) {} + + /** + * Return the size of a cache entry + */ + size_t size() const { return _active ? _size : 0; } +}; + +class CDialogueFile { +private: + File _file; + Common::Array<DialogueIndexEntry> _index; + Common::Array<DialogueResource> _cache; +private: + /** + * Add a dialogue file entry to the active cache + */ + DialogueResource *addToCache(int index); +public: + CDialogueFile(const CString &filename, uint count); + ~CDialogueFile(); + + /** + * Clear the loaded data + */ + void clear(); + + File *getFile() { return &_file; } + + /** + * Sets up a text entry within the dialogue file for access + */ + DialogueResource *openTextEntry(int index) { + return addToCache(index * 2); + } + + /** + * Sets up a wave (sound) entry within the dialogue file for access + */ + DialogueResource *openWaveEntry(int index) { + return addToCache(index * 2 + 1); + } + + /** + * Removes an entry from the cache + */ + bool closeEntry(DialogueResource *cacheEntry); + + /** + * Read data for a resource + */ + bool read(DialogueResource *cacheEntry, byte *buffer, size_t bytesToRead); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TITLE_ENGINE_H */ diff --git a/engines/titanic/true_talk/doorbot_script.cpp b/engines/titanic/true_talk/doorbot_script.cpp new file mode 100644 index 0000000000..1ca1ab13e5 --- /dev/null +++ b/engines/titanic/true_talk/doorbot_script.cpp @@ -0,0 +1,1013 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/doorbot_script.h" +#include "titanic/true_talk/tt_room_script.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +static const int STATE_ARRAY[9] = { + 0x2E2A, 0x2E2B, 0x2E2C, 0x2E2D, 0x2E2E, 0x2E2F, 0x2E30, 0x2E31, 0x2E32 +}; + +static const RoomDialogueId ROOM_DIALOGUES1[] = { + { 100, 10523 }, { 101, 10499 }, { 107, 10516 }, { 108, 10500 }, + { 109, 10490 }, { 110, 10504 }, { 111, 10506 }, { 112, 10498 }, + { 113, 10502 }, { 114, 10507 }, { 115, 10497 }, { 116, 10508 }, + { 117, 10505 }, { 118, 10505 }, { 122, 10516 }, { 123, 10383 }, + { 124, 10510 }, { 125, 10511 }, { 126, 10513 }, { 127, 10512 }, + { 128, 10495 }, { 129, 10496 }, { 130, 10491 }, { 131, 10493 }, + { 132, 10492 }, { 0, 0 } +}; +static const RoomDialogueId ROOM_DIALOGUES2[] = { + { 102, 221981 }, { 110, 221948 }, { 111, 221968 }, { 107, 222000 }, + { 101, 221935 }, { 112, 221924 }, { 113, 221942 }, { 116, 221977 }, + { 124, 221987 }, { 125, 221984 }, { 127, 221991 }, { 128, 221916 }, + { 129, 221919 }, { 131, 221912 }, { 132, 221908 }, { 0, 0 } +}; + +DoorbotScript::DoorbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) { + loadRanges("Ranges/Doorbot"); + loadResponses("Responses/Doorbot"); + setupSentences(); + _tagMappings.load("TagMap/Doorbot"); + _words.load("Words/Doorbot"); + _quotes.load("Quotes/Doorbot"); + _states.load("States/Doorbot"); +} + +void DoorbotScript::setupSentences() { + for (int idx = 35; idx < 40; ++idx) + CTrueTalkManager::setFlags(idx, 0); + _doorbotState = 1; + _field68 = 0; + _entryCount = 0; + _dialValues[0] = _dialValues[1] = 100; + + _mappings.load("Mappings/Doorbot", 4); + _entries.load("Sentences/Doorbot"); + + static const int SENTENCE_NUMS[11] = { + 2, 100, 101, 102, 107, 110, 111, 124, 129, 131, 132 + }; + for (int idx = 0; idx < 11; ++idx) { + _sentences[idx] = TTsentenceEntries(); + _sentences[idx].load(CString::format("Sentences/Doorbot/%d", SENTENCE_NUMS[idx])); + } +} + +int DoorbotScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) { + if (tag == MKTAG('D', 'N', 'A', '1') || tag == MKTAG('H', 'H', 'G', 'Q') || + tag == MKTAG('A', 'N', 'S', 'W') || tag == MKTAG('S', 'U', 'M', 'S')) { + if (_stateIndex > 9) + _stateIndex = 0; + addResponse(STATE_ARRAY[_stateIndex]); + applyResponse(); + + if (STATE_ARRAY[_stateIndex] == 11826) + setState(1); + ++_stateIndex; + return 2; + } + + if (tag == MKTAG('C', 'H', 'S', 'E') || tag == MKTAG('C', 'M', 'N', 'T') || + tag == MKTAG('J', 'F', 'O', 'D')) + tag = MKTAG('F', 'O', 'O', 'D'); + + if (tag == MKTAG('F', 'O', 'O', 'D') && roomScript->_scriptId == 132) { + return setResponse(getDialogueId(220818)); + } + + if (tag == MKTAG('T', 'R', 'A', 'V')) { + return setResponse(11858 - getRandomBit()); + } else if (tag == MKTAG('C', 'S', 'P', 'Y')) { + return setResponse(10405, 3); + } else if (tag == MKTAG('S', 'C', 'I', 'T')) { + return setResponse(10410, 14); + } else if (tag == MKTAG('L', 'I', 'T', 'E')) { + return setResponse(10296, 17); + } else if (tag == MKTAG('D', 'O', 'R', '1')) { + return setResponse(getDialogueId(222034)); + } else if (tag == MKTAG('W', 'T', 'H', 'R')) { + return setResponse(getDialogueId(222126)); + } else if (tag == MKTAG('N', 'A', 'U', 'T')) { + return setResponse(getDialogueId(222259)); + } else if (tag == MKTAG('T', 'R', 'A', '2')) { + return setResponse(getRandomBit() ? 11860 : 11859); + } else if (tag == MKTAG('T', 'R', 'A', '3')) { + return setResponse(getRandomBit() ? 11859 : 11858); + } else if (tag == MKTAG('B', 'R', 'N', 'D')) { + switch (getRandomNumber(3)) { + case 1: + tag = MKTAG('B', 'R', 'N', '2'); + break; + case 2: + tag = MKTAG('B', 'R', 'N', '3'); + break; + default: + break; + } + } + + return TTnpcScript::chooseResponse(roomScript, sentence, tag); +} + +int DoorbotScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + int currState; + + switch (roomScript->_scriptId) { + case 100: + case 101: + case 102: + case 103: + case 104: + case 106: + case 107: + case 108: + case 109: + case 110: + case 111: + case 113: + case 116: + case 117: + case 118: + case 122: + case 123: + case 124: + case 125: + case 126: + case 127: + case 128: + case 129: + case 130: + case 131: + case 132: + break; + + default: + return 2; + } + + checkItems(nullptr, nullptr); + if (getState() == 0) { + if (CTrueTalkManager::_v2 > getValue(36)) { + if (getDialRegion(1) == 1 && getRandomBit()) { + setDialRegion(0, getDialRegion(1) ? 0 : 1); + } else { + setDialRegion(1, getDialRegion(1) ? 0 : 1); + } + CTrueTalkManager::setFlags(36, CTrueTalkManager::_v2 + 3 + getRandomNumber(5)); + + if (getValue(37)) { + CTrueTalkManager::setFlags(37, 0); + setState(0); + return setResponse(getDialogueId(221140)); + } + } + } + + if (getValue(35) == 0 && roomScript->_scriptId != 100 && sentence->localWord("parrot")) { + CTrueTalkManager::setFlags(35, 1); + setState(0); + return setResponse(getDialogueId(220113)); + } + + if (sentence->_field2C == 6 && sentence->contains("why not")) { + return setResponse(11871, 8); + } + + currState = getState(); + if (currState) { + int sentMode = sentence->_field2C; + bool flag1 = sentMode == 11 || sentMode == 13; + bool flag2 = sentMode == 12; + + switch (currState) { + case 1: + if (flag1) + return setResponse(11828, 2); + if (flag2) + return setResponse(11827, 0); + break; + + case 2: + if (flag1) + return setResponse(11827, 0); + break; + + case 3: + if (sentMode == 3) + return setResponse(10406, 0); + break; + + case 4: + if (flag1) + return setResponse(11332, 0); + if (flag2) + return setResponse(11331, 0); + break; + + case 5: + return setResponse(11868, 0); + + case 6: + return setResponse(11872, 0); + + case 7: + return setResponse(11869, 0); + + case 8: + return setResponse(11870, 0); + + case 12: + if (flag1) + return setResponse(11894, 13); + if (flag2) + return setResponse(11893, 13); + break; + + case 13: + return setResponse(11895, 12); + + case 15: + if (sentMode == 3 || sentMode == 6) + return setResponse(10257, 0); + break; + + case 16: { + TTtreeResult treeResult; + if (g_vm->_trueTalkManager->_quotesTree.search(sentence->_normalizedLine.c_str(), + TREE_3, &treeResult, 0, nullptr) != -1) + return setResponse(getDialogueId(221380), 0); + break; + } + + case 17: + return setResponse(getDialogueId(221126), 0); + + case 18: + if (flag1) + return setResponse(getDialogueId(221135), 0); + if (flag2) + return setResponse(getDialogueId(221134), 0); + break; + + case 19: + if (flag1) { + if (addRandomResponse(true)) { + setState(10); + return 2; + } + } + if (flag2) + return setResponse(getDialogueId(221966), 0); + break; + + case 20: + if (flag1) { + if (addRandomResponse(true)) { + setState(19); + return 2; + } + } + if (flag2 || sentMode == 7 || sentMode == 10) { + return setResponse(getDialogueId(221879), 0); + } + break; + + case 21: + if (flag2) + return setResponse(10935, 0); + break; + + case 22: + if (flag1) { + if (getRandomBit()) { + return setResponse(11211, 23); + } else { + return setResponse(10127, 0); + } + } + if (flag2) + return setResponse(10136, 0); + break; + + case 23: + return setResponse(10212, 0); + + case 24: + if (flag1) + return setResponse(11151, 0); + if (flag2) + return setResponse(11150, 0); + break; + + case 25: + case 26: + if (flag2) { + if (getRandomBit()) { + return setResponse(11211, 23); + } else { + return setResponse(10127, 0); + } + } + if (flag1) + return setResponse(10136, 0); + break; + + case 27: + if (flag1 || sentence->localWord("did") || sentence->contains("did")) + return setResponse(221175, 28); + break; + + case 28: + if (flag1 || sentence->localWord("did") || sentence->contains("did")) + return setResponse(getDialogueId(221176), 29); + break; + + case 29: + if (flag1 || sentence->localWord("did") || sentence->contains("did")) + return setResponse(getDialogueId(221177), 30); + break; + + case 30: + return setResponse(getDialogueId(221178), 31); + + case 31: + if (sentMode == 3 || sentMode == 10) + return setResponse(10350, 0); + break; + + case 32: + return setResponse(10110, 0); + + case 33: + if (sentence->contains("sieve") || sentence->contains("colander") + || sentence->contains("vegetable") || sentence->contains("ground") + || sentence->contains("earth") || sentence->contains("garden") + || sentence->contains("cheese") || sentence->contains("strainer")) { + return setResponse(getDialogueId(221375), 0); + } else if (getRandomNumber(100) > 30) { + return setResponse(getDialogueId(221376), 33); + } else { + return setResponse(getDialogueId(221376), 0); + } + break; + + case 34: + if (sentence->localWord("bellbot")) + return setResponse(10094, 0); + if (sentence->localWord("bellbot")) + return setResponse(10349, 0); + if (sentence->localWord("deskbot") || sentence->localWord("titania")) + return setResponse(10148, 0); + if (sentence->localWord("barbot") || sentence->localWord("rowbot") + || sentence->localWord("liftbot") || sentence->localWord("maitredbot")) + return setResponse(10147, 0); + break; + + case 35: + return setResponse(10811, 36); + + case 36: + if (flag1) + return setResponse(10813, 37); + if (flag2) + return setResponse(10812, 37); + break; + + case 37: + if (flag1) + return setResponse(10815, 37); + if (flag2) + return setResponse(10814, 37); + break; + + case 38: + return setResponse(10848, 39); + + case 39: + return setResponse(10823, 40); + + case 40: + return setResponse(10832, 41); + + case 41: + addResponse(10833); + return setResponse(10835, 0); + + case 42: + if (sentence->localWord("please")) + return setResponse(10840, 43); + return setResponse(10844, 0); + + case 43: + case 45: + return setResponse(10844, 0); + + case 44: + if (sentence->localWord("thanks")) + return setResponse(10843, 45); + return setResponse(10844, 0); + + case 46: + if (flag1) + return setResponse(getDialogueId(222251), 0); + if (flag2) + return setResponse(10713, 0); + break; + + } + } + + if (currState != 14) + setState(0); + + if (getDialRegion(1) != 1 && getRandomNumber(100) > 92) + return setResponse(getDialogueId(221043), 0); + + int result = 0; + switch (roomScript->_scriptId) { + case 100: + case 101: + case 102: + case 107: + case 110: + case 111: + case 124: + case 129: + case 131: + case 132: + result = processEntries(&_sentences[roomScript->_scriptId], 0, roomScript, sentence); + break; + default: + break; + } + if (result == 2) + return 2; + + if (processEntries(&_entries, _entryCount, roomScript, sentence) == 2 + || processEntries(_defaultEntries, 0, roomScript, sentence) == 2 + || defaultProcess(roomScript, sentence)) + return 2; + + switch (sentence->_field2C) { + case 11: + if (getRandomNumber(100) > 90) + return setResponse(10839, 42); + return setResponse(222415, 0); + + case 12: + if (getRandomNumber(100) > 90) + return setResponse(10841, 44); + return setResponse(getDialogueId(222416), 0); + + case 13: + return setResponse(getDialogueId(222415), 0); + + default: + if (getRandomNumber(100) > 75 && getStateValue()) + return setResponse(getDialogueId(221095)); + + if (processEntries(&_sentences[2], 0, roomScript, sentence) != 2) + return setResponse(getDialogueId(220000)); + break; + } + + return 2; +} + +ScriptChangedResult DoorbotScript::scriptChanged(const TTroomScript *roomScript, uint id) { + if (id == 3) { + if (roomScript != nullptr && roomScript->_scriptId != 100) { + if (CTrueTalkManager::_v9 == 101) { + addResponse(getDialogueId(220873)); + applyResponse(); + } else { + bool flag = false; + if (CTrueTalkManager::_currentNPC) { + CGameObject *obj; + if (CTrueTalkManager::_currentNPC->find("Magazine", &obj, FIND_PET)) { + setResponse(getDialogueId(222248), 46); + flag = true; + } + } + + if (!flag) { + if (getRandomNumber(100) > 80 && getStateValue()) { + addResponse(getDialogueId(221095)); + applyResponse(); + flag = true; + } + + if (!flag && (_doorbotState || !fn10(true))) { + addResponse(getDialogueId(220074)); + applyResponse(); + } + } + } + } + + _doorbotState = 0; + resetFlags(); + CTrueTalkManager::_v9 = 0; + } else if (id == 4) { + setState(0); + if (getValue(38) == 0) { + addResponse(getDialogueId(220883)); + applyResponse(); + } + + CTrueTalkManager::setFlags(38, 0); + CTrueTalkManager::setFlags(39, 0); + } + + if (id >= 220000 && id <= 222418) { + addResponse(getDialogueId(id)); + applyResponse(); + } else if (id >= 10000 && id <= 11986) { + addResponse(id); + applyResponse(); + } + + return SCR_2; +} + +int DoorbotScript::handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder) { + switch (tagId) { + case MKTAG('A', 'D', 'V', 'T'): + case MKTAG('A', 'R', 'T', 'I'): + case MKTAG('A', 'R', 'T', 'Y'): + case MKTAG('B', 'R', 'N', 'D'): + case MKTAG('C', 'O', 'M', 'D'): + case MKTAG('D', 'N', 'C', 'E'): + case MKTAG('H', 'B', 'B', 'Y'): + case MKTAG('L', 'I', 'T', 'R'): + case MKTAG('M', 'A', 'G', 'S'): + case MKTAG('M', 'C', 'P', 'Y'): + case MKTAG('M', 'I', 'N', 'S'): + case MKTAG('M', 'U', 'S', 'I'): + case MKTAG('N', 'I', 'K', 'E'): + case MKTAG('S', 'F', 'S', 'F'): + case MKTAG('S', 'O', 'A', 'P'): + case MKTAG('S', 'O', 'N', 'G'): + case MKTAG('S', 'P', 'R', 'T'): + case MKTAG('T', 'E', 'A', 'M'): + case MKTAG('T', 'V', 'S', 'H'): + case MKTAG('W', 'W', 'E', 'B'): + tagId = MKTAG('E', 'N', 'T', 'N'); + break; + case MKTAG('A', 'C', 'T', 'R'): + case MKTAG('A', 'C', 'T', 'S'): + case MKTAG('A', 'U', 'T', 'H'): + case MKTAG('B', 'A', 'R', 'K'): + case MKTAG('B', 'A', 'R', 'U'): + case MKTAG('B', 'L', 'F', '1'): + case MKTAG('B', 'L', 'F', '2'): + case MKTAG('B', 'L', 'P', '1'): + case MKTAG('B', 'L', 'P', '2'): + case MKTAG('B', 'L', 'P', '3'): + case MKTAG('B', 'L', 'P', '4'): + case MKTAG('B', 'L', 'T', '1'): + case MKTAG('B', 'L', 'T', '2'): + case MKTAG('B', 'L', 'T', '3'): + case MKTAG('B', 'L', 'T', '4'): + case MKTAG('B', 'L', 'T', '5'): + case MKTAG('B', 'O', 'Y', 'S'): + case MKTAG('D', 'C', 'T', 'R'): + case MKTAG('F', 'A', 'M', 'E'): + case MKTAG('F', 'A', 'S', 'H'): + case MKTAG('G', 'I', 'R', 'L'): + case MKTAG('H', 'E', 'R', 'O'): + case MKTAG('H', 'O', 'S', 'T'): + case MKTAG('K', 'N', 'O', 'B'): + case MKTAG('N', 'H', 'R', 'O'): + case MKTAG('R', 'A', 'C', 'E'): + case MKTAG('S', 'C', 'I', 'T'): + case MKTAG('T', 'D', 'V', 'P'): + case MKTAG('T', 'W', 'A', 'T'): + case MKTAG('W', 'E', 'A', 'T'): + tagId = MKTAG('P', 'R', 'S', 'N'); + break; + case MKTAG('C', 'H', 'S', 'E'): + case MKTAG('C', 'M', 'N', 'T'): + case MKTAG('F', 'I', 'L', 'M'): + case MKTAG('J', 'F', 'O', 'D'): + case MKTAG('L', 'I', 'Q', 'D'): + tagId = MKTAG('F', 'O', 'O', 'D'); + break; + case MKTAG('C', 'R', 'I', 'M'): + case MKTAG('C', 'S', 'P', 'Y'): + case MKTAG('D', 'R', 'U', 'G'): + tagId = MKTAG('V', 'B', 'A', 'D'); + break; + case MKTAG('E', 'A', 'R', 'T'): + case MKTAG('H', 'O', 'M', 'E'): + case MKTAG('N', 'P', 'L', 'C'): + case MKTAG('P', 'L', 'A', 'N'): + tagId = MKTAG('P', 'L', 'A', 'C'); + break; + case MKTAG('F', 'A', 'U', 'N'): + case MKTAG('F', 'I', 'S', 'H'): + case MKTAG('F', 'L', 'O', 'R'): + tagId = MKTAG('N', 'A', 'T', 'R'); + break; + case MKTAG('H', 'H', 'L', 'D'): + case MKTAG('T', 'O', 'Y', 'S'): + case MKTAG('W', 'E', 'A', 'P'): + tagId = MKTAG('M', 'A', 'C', 'H'); + break; + case MKTAG('M', 'L', 'T', 'Y'): + case MKTAG('P', 'G', 'R', 'P'): + case MKTAG('P', 'T', 'I', 'C'): + tagId = MKTAG('G', 'R', 'U', 'P'); + break; + case MKTAG('P', 'K', 'U', 'P'): + case MKTAG('S', 'E', 'X', '1'): + case MKTAG('S', 'W', 'E', 'R'): + tagId = MKTAG('R', 'U', 'D', 'E'); + break; + case MKTAG('P', 'H', 'I', 'L'): + case MKTAG('R', 'C', 'K', 'T'): + tagId = MKTAG('S', 'C', 'I', 'E'); + break; + case MKTAG('T', 'R', 'A', '2'): + case MKTAG('T', 'R', 'A', '3'): + tagId = MKTAG('T', 'R', 'A', 'V'); + break; + default: + break; + } + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); +} + +int DoorbotScript::updateState(uint oldId, uint newId, int index) { + getValue(38); + bool flag39 = getValue(39) != 0; + CTrueTalkManager::setFlags(38, 0); + CTrueTalkManager::setFlags(39, 0); + + if (newId > 220890) { + switch (newId) { + case 221064: + return getValue(1) == 2 ? newId : 221062; + case 221080: + return getValue(1) >= 2 ? newId : 221066; + case 221078: + case 221079: + return getValue(1) >= 3 ? newId : 221065; + case 221081: + return getValue(7) == 0 ? newId : 221070; + case 221251: + CTrueTalkManager::triggerAction(28, 0); + break; + default: + break; + } + } else if (newId >= 220883) { + CTrueTalkManager::setFlags(38, 1); + CTrueTalkManager::triggerAction(28, 0); + } else if (newId >= 220076) { + switch (newId) { + case 220078: + case 220080: + case 220081: + case 220082: + case 220083: + case 220084: + if (flag39) + return getRangeValue(221381); + break; + default: + break; + } + + CTrueTalkManager::setFlags(39, 1); + } else if (newId == 220075) { + if (flag39) + return getRangeValue(221381); + CTrueTalkManager::setFlags(39, 1); + } else if (newId == 220038) { + return 220038; + } + + for (uint idx = 0; idx < _states.size(); ++idx) { + TTupdateState &us = _states[idx]; + if (us._newId == newId) { + uint bits = us._dialBits; + + if (!bits + || (index == 0 && (bits == 5 || bits == 1)) + || (index == 1 && (bits == 6 || bits == 2)) + || (index == 2 && (bits == 9 || bits == 1)) + || (index == 3 && (bits == 10 || bits == 2))) { + setState(us._newValue); + break; + } + } + } + + return newId; +} + +int DoorbotScript::preResponse(uint id) { + uint newId = 0; + if (getDialRegion(0) != 1 && getRandomNumber(100) > 60) { + addResponse(11195); + newId = 222193; + } + + return newId; +} + +uint DoorbotScript::getDialsBitset() const { + uint bits = 0; + if (!getDialRegion(1)) + bits = 1; + if (!getDialRegion(0)) + bits |= 2; + + return bits; +} + +int DoorbotScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + int id2, id = 0; + + switch (val1) { + case 2: + if (getValue(1) != 1) + return 1; + break; + case 3: + if (getValue(1) != 2) + return 1; + break; + case 4: + if (getValue(1) != 3) + return 1; + break; + case 5: + if (getValue(1) == 3) + return 1; + case 6: + if (getRoom54(132)) + return 1; + break; + case 9: + if (sentence->localWord("my") || sentence->contains("my")) + return true; + id2 = getRoomDialogueId1(roomScript); + if (id2) { + addResponse(id2); + applyResponse(); + return 2; + } + break; + case 11: + switch (getValue(1)) { + case 1: + id = 220837; + break; + case 2: + id = 220849; + break; + default: + id = 220858; + break; + } + break; + case 12: + if (getValue(4) != 1) + id = 221157; + break; + case 13: + if (getValue(4) != 2) + id = 221157; + break; + case 14: + if (getValue(4) != 3) + id = 221157; + break; + case 15: + if (getValue(4) != 0) + id = 221157; + break; + case 16: + if (!sentence->localWord("weather")) + return true; + switch (getRandomNumber(4)) { + case 1: + if (getValue(4) != 0) + id = 221354 - getRandomNumber(2) ? -489 : 0; + break; + case 2: + switch (getValue(4)) { + case 0: + id = 220851; + break; + case 1: + id = 221268; + break; + case 2: + id = 221270; + break; + default: + id = 220865; + } + break; + case 3: + id = 221280; + break; + default: + break; + } + break; + case 17: + if (getState()) + return 1; + setState(0); + break; + case 18: + if (roomScript->_scriptId == 100) { + CTrueTalkManager::triggerAction(3, 0); + return 2; + } + break; + case 19: + CTrueTalkManager::_v9 = 104; + CTrueTalkManager::triggerAction(4, 0); + break; + case 20: + CTrueTalkManager::triggerAction(28, 0); + break; + case 22: + CTrueTalkManager::triggerAction(29, 1); + break; + case 23: + CTrueTalkManager::triggerAction(29, 2); + break; + case 24: + CTrueTalkManager::triggerAction(29, 3); + break; + case 25: + CTrueTalkManager::triggerAction(29, 4); + break; + case 26: + if (!sentence->localWord("my") && !sentence->contains("my")) + return 1; + break; + case 27: + if (!sentence->localWord("earth") && !sentence->contains("earth")) + return 1; + break; + case 28: + id2 = getRoomDialogueId2(roomScript); + if (id2) { + addResponse(id2); + applyResponse(); + return 2; + } + break; + case 29: + if (sentence->localWord("another") || sentence->localWord("more") || + sentence->localWord("additional") || sentence->contains("another") || + sentence->contains("more") || sentence->contains("additional")) { + addResponse(getDialogueId(220058)); + applyResponse(); + return 2; + } + break; + case 30: + if (!sentence->localWord("because") && !sentence->contains("because")) + return 1; + break; + case 0x200: + if (getValue(4) != 1) + id = 221157; + break; + case 0x201: + if (getValue(4) != 2) + id = 221157; + break; + case 0x202: + if (getValue(4) != 3) + id = 221157; + break; + case 0x203: + if (getValue(4) != 0) + id = 221157; + break; + default: + break; + } + + if (id) { + addResponse(getDialogueId(id)); + applyResponse(); + return 2; + } else { + return 0; + } +} + +void DoorbotScript::setDialRegion(int dialNum, int region) { + TTnpcScript::setDialRegion(dialNum, region); + if (dialNum == 1 && region != 1) { + CTrueTalkManager::setFlags(37, dialNum); + } else { + addResponse(getDialogueId(221777)); + applyResponse(); + } +} + +bool DoorbotScript::randomResponse(uint index) { + static const int DIALOGUE_IDS[] = { + 220133, 220074, 220000, 220008, 220009, 220010, 220011, + 220012, 220013, 220014, 220015, 220016, 221053, 221054, + 221055, 221056, 221057, 221058, 221059, 221060, 221061, + 221173, 221174, 221175, 221176, 221177, 222415, 222416, + 221157, 221165, 221166, 221167, 221168, 221169, 221170, + 221171, 221172, 221158, 221159, 221356, 221364, 221365, + 221366, 221367, 221368, 221369, 221370, 221371, 221357, + 221358, 221359, 221360, 221252, 221019, 221355, 220952, + 220996, 220916, 220924, 220926, 220931, 220948, 220956, + 220965, 220967, 220968, 220980, 220981, 220982, 220983, + 220984, 220988, 220903, 221095, 222202, 222239, 221758, + 221759, 221762, 221763, 221766, 221767, 221768, 0 + }; + + int *dataP = _data.getSlot(index); + bool flag = false; + for (const int *idP = DIALOGUE_IDS; *idP && !flag; ++idP) { + flag = *idP == *dataP; + } + + if (flag || (getDialRegion(1) != 1 && getRandomNumber(100) > 33) + || getRandomNumber(8) <= index) + return false; + + if (getRandomNumber(100) > 40) { + deleteResponses(); + addResponse(getDialogueId(221242)); + applyResponse(); + } else { + setResponseFromArray(index, 221245); + } + + return true; +} + +int DoorbotScript::setResponse(int dialogueId, int v34) { + addResponse(dialogueId); + applyResponse(); + + if (v34 != -1) + setState(v34); + return 2; +} + +int DoorbotScript::getRoomDialogueId1(const TTroomScript *roomScript) { + for (const RoomDialogueId *r = ROOM_DIALOGUES1; r->_roomNum; ++r) { + if (r->_roomNum == roomScript->_scriptId) + return getDialogueId(r->_dialogueId); + } + + return 0; +} + +int DoorbotScript::getRoomDialogueId2(const TTroomScript *roomScript) { + for (const RoomDialogueId *r = ROOM_DIALOGUES2; r->_roomNum; ++r) { + if (r->_roomNum == roomScript->_scriptId) + return getDialogueId(r->_dialogueId); + } + + return 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/doorbot_script.h b/engines/titanic/true_talk/doorbot_script.h new file mode 100644 index 0000000000..78ebcbfd68 --- /dev/null +++ b/engines/titanic/true_talk/doorbot_script.h @@ -0,0 +1,113 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_DOORBOT_SCRIPT_H +#define TITANIC_DOORBOT_SCRIPT_H + +#include "common/hashmap.h" +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class DoorbotScript : public TTnpcScript { + typedef Common::HashMap<uint, TTsentenceEntries> SentenceEntriesMap; +private: + TTupdateStateArray _states; + SentenceEntriesMap _sentences; + int _stateIndex; + int _doorbotState; +private: + /** + * Setup sentence data + */ + void setupSentences(); + + /** + * Sets a response + */ + int setResponse(int dialogueId, int v34 = -1); + + /** + * Gets the dialogue Id for a given room + */ + int getRoomDialogueId1(const TTroomScript *roomScript); + + /** + * Gets the dialogue Id for a given room + */ + int getRoomDialogueId2(const TTroomScript *roomScript); +public: + DoorbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + virtual int handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + + /** + * Returns a bitset of the dials being off or not + */ + virtual uint getDialsBitset() const; + + /** + * Process a sentence fragment entry + */ + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Sets a given dial to be pointing in a specified region (0 to 2) + */ + virtual void setDialRegion(int dialNum, int region); + + /** + * Handles a randomzied response + */ + virtual bool randomResponse(uint index); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_DOORBOT_SCRIPT_H */ diff --git a/engines/titanic/true_talk/liftbot_script.cpp b/engines/titanic/true_talk/liftbot_script.cpp new file mode 100644 index 0000000000..ab995b71b9 --- /dev/null +++ b/engines/titanic/true_talk/liftbot_script.cpp @@ -0,0 +1,695 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/liftbot_script.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +int LiftbotScript::_stateIndex; + +static const int STATE_ARRAY[7] = { + 0x78BE, 0x78C0, 0x78C1, 0x78C2, 0x78C3, 0x78C4, 0x78C5 +}; + +LiftbotScript::LiftbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) { + _stateIndex = 0; + + loadRanges("Ranges/Liftbot"); + loadResponses("Responses/Liftbot"); + setupSentences(); + _tagMappings.load("TagMap/Liftbot"); + _words.load("Words/Liftbot"); + _quotes.load("Quotes/Liftbot"); + _states.load("States/Liftbot"); +} + +void LiftbotScript::setupSentences() { + CTrueTalkManager::setFlags(27, 0); + setupDials(getRandomNumber(40) + 60, getRandomNumber(40) + 60, 0); + + _mappings.load("Mappings/Liftbot", 4); + _entries.load("Sentences/Liftbot"); + _field68 = 0; + _entryCount = 0; +} + +int LiftbotScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) { + switch (tag) { + case MKTAG('D', 'N', 'A', '1'): + case MKTAG('H', 'H', 'G', 'Q'): + case MKTAG('A', 'N', 'S', 'W'): + if (_stateIndex >= 7) { + selectResponse(30918); + setState(2); + _stateIndex = 0; + } else { + addResponse(STATE_ARRAY[_stateIndex++]); + } + + applyResponse(); + return 2; + + case MKTAG('O', 'R', 'D', '8'): + addResponse(30475); + addResponse(30467); + addResponse(30466); + addResponse(30474); + applyResponse(); + return SS_2; + + default: + return TTnpcScript::chooseResponse(roomScript, sentence, tag); + } +} + +int LiftbotScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + if (roomScript->_scriptId != 103) + return 2; + + checkItems(roomScript, sentence); + int currState = getState(); + int sentMode = sentence->_field2C; + TTtreeResult treeResult; + + if (currState) { + setState(0); + bool flag1 = sentMode == 11 || sentMode == 13; + bool flag2 = sentMode == 12; + + switch (currState) { + case 2: + if (flag1) + return addDialogueAndState(30920, 3); + if (flag2) + return addDialogueAndState(30919, 1); + break; + + case 3: + if (flag1) + return addDialogueAndState(30919, 1); + break; + + case 4: + return addDialogueAndState(210391, 1); + + case 5: + if (sentence->contains("reborzo") || sentence->contains("is that")) + return addDialogueAndState(30515, 1); + break; + + case 6: + if (sentMode == 6) + return addDialogueAndState(getDialogueId(210771), 1); + break; + + case 7: + case 8: + if (sentMode == 6 || sentMode == 10) + return addDialogueAndState(getDialogueId(210099), 1); + break; + + case 9: + if (sentMode == 10 || g_vm->_trueTalkManager->_quotesTree.search( + sentence->_normalizedLine.c_str(), TREE_2, &treeResult, 0, 0) != -1) + return addDialogueAndState(getDialogueId(210970), 9); + break; + + default: + break; + } + } + + updateCurrentDial(true); + if (processEntries(&_entries, _entryCount, roomScript, sentence) == 2) + return 2; + + if (sentence->localWord("injury") || sentence->localWord("illness")) { + addResponse(getDialogueId(210059)); + applyResponse(); + } else if (processEntries(_defaultEntries, 0, roomScript, sentence) != 2 + && !defaultProcess(roomScript, sentence) + && !sentence1(sentence)) { + if (getDialRegion(1) != 0 && getRandomNumber(100) <= 20) { + addResponse(getDialogueId(210906)); + addResponse(getDialogueId(210901)); + } else { + addResponse(getDialogueId(210590)); + } + applyResponse(); + } + + return 2; +} + +ScriptChangedResult LiftbotScript::scriptChanged(uint id) { + return scriptChanged(nullptr, id); +} + +ScriptChangedResult LiftbotScript::scriptChanged(const TTroomScript *roomScript, uint id) { + switch (id) { + case 3: + if (getValue(27) == 0) { + addResponse(getDialogueId(210018)); + } else if (getStateValue()) { + addResponse(getDialogueId(210682)); + } else { + addResponse(getDialogueId(210033)); + } + CTrueTalkManager::setFlags(27, 1); + break; + + case 155: + selectResponse(30446); + applyResponse(); + break; + + case 156: + if (getCurrentFloor() == 1) { + addResponse(getDialogueId(210614)); + } else { + selectResponse(30270); + } + applyResponse(); + break; + + default: + break; + } + + if (id >= 210000 && id <= 211001) { + addResponse(getDialogueId(id)); + applyResponse(); + } + + return SCR_2; +} + +int LiftbotScript::handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder) { + switch (tagId) { + case MKTAG('A', 'D', 'V', 'T'): + case MKTAG('A', 'R', 'T', 'I'): + case MKTAG('A', 'R', 'T', 'Y'): + case MKTAG('B', 'R', 'N', 'D'): + case MKTAG('C', 'O', 'M', 'D'): + case MKTAG('D', 'N', 'C', 'E'): + case MKTAG('H', 'B', 'B', 'Y'): + case MKTAG('L', 'I', 'T', 'R'): + case MKTAG('M', 'A', 'G', 'S'): + case MKTAG('M', 'C', 'P', 'Y'): + case MKTAG('M', 'I', 'N', 'S'): + case MKTAG('M', 'U', 'S', 'I'): + case MKTAG('N', 'I', 'K', 'E'): + case MKTAG('S', 'F', 'S', 'F'): + case MKTAG('S', 'O', 'A', 'P'): + case MKTAG('S', 'O', 'N', 'G'): + case MKTAG('S', 'P', 'R', 'T'): + case MKTAG('T', 'E', 'A', 'M'): + case MKTAG('T', 'V', 'S', 'H'): + case MKTAG('W', 'W', 'E', 'B'): + tagId = MKTAG('E', 'N', 'T', 'N'); + break; + case MKTAG('A', 'C', 'T', 'R'): + case MKTAG('A', 'C', 'T', 'S'): + case MKTAG('A', 'U', 'T', 'H'): + case MKTAG('B', 'A', 'R', 'K'): + case MKTAG('B', 'A', 'R', 'U'): + case MKTAG('B', 'L', 'F', '1'): + case MKTAG('B', 'L', 'F', '2'): + case MKTAG('B', 'L', 'R', '1'): + case MKTAG('B', 'L', 'R', '2'): + case MKTAG('B', 'L', 'P', '1'): + case MKTAG('B', 'L', 'P', '2'): + case MKTAG('B', 'L', 'P', '3'): + case MKTAG('B', 'L', 'P', '4'): + case MKTAG('B', 'L', 'T', '1'): + case MKTAG('B', 'L', 'T', '2'): + case MKTAG('B', 'L', 'T', '3'): + case MKTAG('B', 'L', 'T', '4'): + case MKTAG('B', 'L', 'T', '5'): + case MKTAG('B', 'O', 'Y', 'S'): + case MKTAG('C', 'O', 'P', 'S'): + case MKTAG('D', 'C', 'T', 'R'): + case MKTAG('F', 'A', 'M', 'E'): + case MKTAG('F', 'A', 'S', 'H'): + case MKTAG('G', 'I', 'R', 'L'): + case MKTAG('H', 'E', 'R', 'O'): + case MKTAG('H', 'O', 'S', 'T'): + case MKTAG('K', 'N', 'O', 'B'): + case MKTAG('N', 'H', 'R', 'O'): + case MKTAG('R', 'A', 'C', 'E'): + case MKTAG('S', 'C', 'I', 'T'): + case MKTAG('T', 'D', 'V', 'P'): + case MKTAG('T', 'W', 'A', 'T'): + case MKTAG('W', 'E', 'A', 'T'): + tagId = MKTAG('P', 'R', 'S', 'N'); + break; + case MKTAG('C', 'H', 'S', 'E'): + case MKTAG('C', 'M', 'N', 'T'): + case MKTAG('F', 'I', 'L', 'M'): + case MKTAG('J', 'F', 'O', 'D'): + case MKTAG('L', 'I', 'Q', 'D'): + tagId = MKTAG('F', 'O', 'O', 'D'); + break; + case MKTAG('C', 'R', 'I', 'M'): + case MKTAG('C', 'S', 'P', 'Y'): + case MKTAG('D', 'R', 'U', 'G'): + tagId = MKTAG('V', 'B', 'A', 'D'); + break; + case MKTAG('E', 'A', 'R', 'T'): + case MKTAG('H', 'O', 'M', 'E'): + case MKTAG('N', 'P', 'L', 'C'): + case MKTAG('P', 'L', 'A', 'N'): + tagId = MKTAG('P', 'L', 'A', 'C'); + break; + case MKTAG('F', 'A', 'U', 'N'): + case MKTAG('F', 'I', 'S', 'H'): + case MKTAG('F', 'L', 'O', 'R'): + tagId = MKTAG('N', 'A', 'T', 'R'); + break; + case MKTAG('H', 'H', 'L', 'D'): + case MKTAG('T', 'O', 'Y', 'S'): + case MKTAG('W', 'E', 'A', 'P'): + tagId = MKTAG('M', 'A', 'C', 'H'); + break; + case MKTAG('M', 'L', 'T', 'Y'): + case MKTAG('P', 'G', 'R', 'P'): + case MKTAG('P', 'T', 'I', 'C'): + tagId = MKTAG('G', 'R', 'U', 'P'); + break; + case MKTAG('P', 'K', 'U', 'P'): + case MKTAG('S', 'E', 'X', '1'): + case MKTAG('S', 'W', 'E', 'R'): + tagId = MKTAG('R', 'U', 'D', 'E'); + break; + case MKTAG('P', 'H', 'I', 'L'): + case MKTAG('R', 'C', 'K', 'T'): + tagId = MKTAG('S', 'C', 'I', 'E'); + break; + case MKTAG('T', 'R', 'A', '2'): + case MKTAG('T', 'R', 'A', '3'): + tagId = MKTAG('T', 'R', 'A', 'V'); + break; + } + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); +} + +int LiftbotScript::updateState(uint oldId, uint newId, int index) { + for (uint idx = 0; idx < _states.size(); ++idx) { + TTmapEntry &us = _states[idx]; + if (us._src == newId) { + setState(us._dest); + break; + } + } + + return newId; +} + +int LiftbotScript::preResponse(uint id) { + if (id == 30565 || id == 30566 || id == 30567 || id == 30568 + || id == 30569 || id == 30570 || id == 30571) + return 210901; + + if (getDialRegion(0) == 0 && getRandomNumber(100) > 60) + return 210830; + + return 0; +} + +uint LiftbotScript::getDialsBitset() const { + uint bits = 0; + if (!getDialRegion(1)) + bits = 1; + if (!getDialRegion(0)) + bits |= 2; + if (bits > 1) + bits ^= 1; + + return bits; +} + + +int LiftbotScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + static const int ARRAY13[] = { + 210724, 210735, 210746, 210757, 210758, 210759, 210760, + 210761, 210762, 210725, 210726, 210727, 210728, 210729, + 210730, 210731, 210732, 210733, 210734, 210736, 210737, + 210738, 210739, 210740, 210741, 210742, 210743, 210744, + 210745, 210747, 210748, 210749, 210750, 210751, 210752, + 210753, 210754, 210755, 210756 + }; + static const int ARRAY14[] = { + 0, 210849, 210850, 210851, 210852, 210838, 210839, 210840, 210841, 0 + }; + + getState(); + int stateVal; + + switch (val1) { + case 1: + if (getValue(1) != 1) + return 1; + break; + case 2: + if (getValue(1) != 2) + return 1; + break; + case 3: + if (getValue(1) != 3) + return 1; + break; + case 4: + case 5: + return !sentence1(sentence); + case 6: + if (sentence->localWord("big") || sentence->localWord("small")) { + addResponse(getDialogueId(210215)); + applyResponse(); + } else if (sentence->localWord("my") || sentence->contains("my") || + sentence->contains("bedroom") || sentence->contains("state")) { + addResponse1(CTrueTalkManager::getStateValue(4), true, 0); + } else { + selectResponse(210763); + applyResponse(); + } + return 2; + case 7: + if (!sentence->localWord("ill") && !sentence->localWord("well")) + return 1; + break; + case 8: + if (!sentence->localWord("long")) + return 1; + break; + case 9: + if (addResponse1(1, false, 0)) + return 2; + break; + case 10: + if (addResponse1(39, false, 0)) + return 2; + break; + case 11: + if (getState6() == 2 || getState6() == 4) + return 1; + break; + case 12: + if (getState6() == 1 || getState6() == 3) + return 1; + break; + case 13: + selectResponse(ARRAY13[getCurrentFloor()]); + applyResponse(); + return 2; + case 14: + stateVal = getState6(); + if (sentence->contains("elevator") || + (!sentence->contains("lift") && getRandomNumber(100) > 60)) + stateVal += 4; + selectResponse(ARRAY14[stateVal]); + applyResponse(); + return 2; + case 15: + if (getRandomNumber(100) > 60) { + addResponse(getDialogueId(210440)); + } else { + addResponse(getDialogueId(210906)); + addResponse(getDialogueId(210901)); + } + applyResponse(); + return 2; + case 16: + if (sentence->contains("elevator") || sentence->contains("elavator")) + addResponse(30579); + else + addResponse(30580); + applyResponse(); + return 2; + case 17: + if (sentence->localWord("restaurant") || sentence->contains("restaurant")) + return 1; + break; + default: + break; + } + + return 0; +} + +void LiftbotScript::setDialRegion(int dialNum, int region) { + TTnpcScript::setDialRegion(dialNum, region); + addResponse(getDialogueId(210688)); + applyResponse(); +} + +int LiftbotScript::getCurrentFloor() const { + int val = CTrueTalkManager::getStateValue(5); + return CLIP(val, 1, 39); +} + +int LiftbotScript::getState6() const { + int val = CTrueTalkManager::getStateValue(6); + return (val < 1 || val > 4) ? 1 : val; +} + +int LiftbotScript::addDialogueAndState(int id, int state) { + addResponse(id); + applyResponse(); + + if (state != 1) + setState(state); + return 2; +} + +int LiftbotScript::addResponse1(int index, bool flag, int id) { + static const int DIALOGUE_IDS[37] = { + 210735, 210746, 210757, 210758, 210759, 210760, 210761, 210762, + 210725, 210726, 210727, 210728, 210729, 210730, 210731, 210732, + 210733, 210734, 210736, 210737, 210738, 210739, 210740, 210741, + 210742, 210743, 210744, 210745, 210747, 210748, 210749, 210750, + 210751, 210752, 210753, 210754, 210755 + }; + + int stateVal = getState6(); + int maxIndex = (stateVal == 2 || stateVal == 4) ? 27 : 39; + + if (index < 1 || index > maxIndex) { + addResponse(getDialogueId(maxIndex == 27 ? 210587 : 210586)); + applyResponse(); + return 1; + } else if (index == getCurrentFloor()) { + if (index == 1) { + addResponse(30558 - getRandomBit() ? 290 : 0); + addResponse(getDialogueId(210589)); + } else { + if (index == 39) + addResponse(30346); + addResponse(getDialogueId(210589)); + } + + applyResponse(); + return 2; + } + + stateVal = getValue(1); + if (index >= 2 && index <= 19 && stateVal > 1) { + addResponse(getDialogueId(210203)); + applyResponse(); + setState(7); + return true; + } + + if (index >= 20 && index <= 27 && stateVal > 2) { + addResponse(getDialogueId(210210)); + applyResponse(); + setState(8); + return true; + } + + if (flag) { + if (index == 1) { + selectResponse(30558 - getRandomBit() ? 290 : 0); + } else if (index == 39) { + addResponse(30346); + } else { + if (getRandomNumber(100) > 35 && index >= 2 && index <= 38) { + addResponse(getDialogueId(DIALOGUE_IDS[index - 2])); + } + + addResponse(getDialogueId(210588)); + } + + if (id) { + if (id == 210717 || id == 210716 || id == 210719 || id == 210718) { + addResponse(getDialogueId(210720)); + addResponse(getDialogueId(id)); + addResponse(getDialogueId(210715)); + } else { + addResponse(getDialogueId(id)); + } + } + + applyResponse(); + } + + CTrueTalkManager::triggerAction(2, index); + return flag; +} + +int LiftbotScript::sentence1(const TTsentence *sentence) { + if (CTrueTalkManager::_v1 >= 0) { + if (sentence->localWord("room")) { + addResponse1(getStateValue(), true, 0); + } else if (CTrueTalkManager::_v1 >= 1 && CTrueTalkManager::_v1 <= 39) { + if (CTrueTalkManager::_v1 != 1 || !sentence->localWord("floor")) { + addResponse1(CTrueTalkManager::_v1, true, 0); + } else if (sentence->localWord("up") || sentence->localWord("above")) { + addResponse1(getCurrentFloor() - 1, true, 0); + } else if (sentence->localWord("down") || sentence->localWord("below")) { + addResponse1(getCurrentFloor() + 1, true, 0); + } else { + addResponse1(CTrueTalkManager::_v1, true, 0); + } + } + return 1; + } + + int classNum = 1; + bool classSet = true; + if (sentence->localWord("firstclass")) + classNum = 1; + else if (sentence->localWord("secondclass")) + classNum = 2; + else if (sentence->localWord("thirdclass")) + classNum = 3; + else + classSet = false; + + uint newId = 0; + int diff = 1; + if (sentence->localWord("promenade")) { + newId = 210718; + } else if (sentence->localWord("bar")) { + newId = 210894 - (getRandomBit() ? 178 : 0); + } else if (sentence->localWord("musicroom")) { + newId = 210897 - (getRandomBit() ? 180 : 0); + } else if (sentence->localWord("creatorroom")) { + newId = 210713; + } else if (sentence->localWord("sculpture") || sentence->localWord("sculptureroom")) { + newId = 210722; + } else if (sentence->localWord("embarklobby")) { + newId = 210714; + } else if (sentence->localWord("parrotlobby")) { + newId = 210721; + } else if (sentence->localWord("arboretum")) { + newId = 210711; + } else if (sentence->localWord("canal")) { + newId = 210896; + } else if (sentence->localWord("bar")) { + newId = 210894; + } else if (sentence->localWord("bilgeroom")) { + newId = 210895; + } else if (sentence->localWord("titaniaroom")) { + newId = 210723; + } else if (sentence->localWord("restaurant")) { + if (classNum == 1) { + newId = 210719; + diff = 1; + } else { + newId = 210898; + diff = -98; + } + } else if (sentence->localWord("topwell") || sentence->localWord("servicelift") + || sentence->localWord("bridge") || sentence->localWord("dome") + || sentence->localWord("pellerator") || sentence->localWord("top")) { + diff = 1; + } else { + diff = -100; + } + + if (sentence->localWord("lobby")) + diff = (getValue(1) == 0 ? 1 : 0) - 99; + if (sentence->localWord("bottomofwell") || sentence->contains("bottom")) + diff = 39; + + if (diff == -99 || (diff == -100 && classSet)) { + if (classNum == 1) + addResponse(getDialogueId(210235)); + else if (classNum == 2) + addResponse(getDialogueId(210241)); + else + addResponse(getDialogueId(210242)); + applyResponse(); + + return 1; + } + + if (sentence->_field2C == 4 || sentence->localWord("find") + || sentence->contains("get to")) { + if (getCurrentFloor() != diff) { + selectResponse(diff == 1 ? 210769 : 210764); + applyResponse(); + } else if (!newId) { + selectResponse(210764); + applyResponse(); + } else if (newId >= 210715 && newId <= 210719) { + selectResponse(newId); + applyResponse(); + } else { + addResponse(getDialogueId(210720)); + selectResponse(210715); + applyResponse(); + } + + return 1; + } + + if (diff == -98) { + addResponse1(getStateValue(), true, newId); + return 1; + } else if (diff >= 0) { + addResponse1(diff, true, newId); + return 1; + } else if (sentence->localWord("up") || sentence->localWord("ascend")) { + selectResponse(210128); + applyResponse(); + return 1; + } else if (sentence->localWord("down") || sentence->localWord("descend")) { + selectResponse(210138); + applyResponse(); + return 1; + } else if (diff >= 0) { + addResponse1(diff, true, newId); + return 1; + } else { + return 0; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/liftbot_script.h b/engines/titanic/true_talk/liftbot_script.h new file mode 100644 index 0000000000..0a9cdfd6f0 --- /dev/null +++ b/engines/titanic/true_talk/liftbot_script.h @@ -0,0 +1,109 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_LIFTBOT_SCRIPT_H +#define TITANIC_LIFTBOT_SCRIPT_H + +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class LiftbotScript : public TTnpcScript { +private: + TTmapEntryArray _states; + static int _stateIndex; +private: + /** + * Setup sentence data + */ + void setupSentences(); + + int addResponse1(int mode, bool flag, int id); + int sentence1(const TTsentence *sentence); + + /** + * Gets the current floor + */ + int getCurrentFloor() const; + + int getState6() const; + + /** + * Adds a dialogue response and sets the state + */ + int addDialogueAndState(int id, int state); +public: + LiftbotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(uint id); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + virtual int handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + + /** + * Returns a bitset of the dials being off or not + */ + virtual uint getDialsBitset() const; + + /** + * Process a sentence fragment entry + */ + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Sets a given dial to be pointing in a specified region (0 to 2) + */ + virtual void setDialRegion(int dialNum, int region); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_LIFTBOT_SCRIPT_H */ diff --git a/engines/titanic/true_talk/maitred_script.cpp b/engines/titanic/true_talk/maitred_script.cpp new file mode 100644 index 0000000000..e0636d045f --- /dev/null +++ b/engines/titanic/true_talk/maitred_script.cpp @@ -0,0 +1,1057 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/maitred_script.h" +#include "titanic/true_talk/true_talk_manager.h" + +namespace Titanic { + +MaitreDScript::MaitreDScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, -1, -1, -1, 0) { + _answerCtr = 0; + + CTrueTalkManager::setFlags(9, 1); + CTrueTalkManager::setFlags(10, 0); + CTrueTalkManager::setFlags(11, 0); + CTrueTalkManager::setFlags(12, 0); + CTrueTalkManager::setFlags(13, 0); + CTrueTalkManager::setFlags(14, 0); + CTrueTalkManager::setFlags(15, 0); + CTrueTalkManager::setFlags(16, 0); + + loadRanges("Ranges/MaitreD"); + loadResponses("Responses/MaitreD"); + setupSentences(); + _tagMappings.load("TagMap/MaitreD"); + _quotes.load("Quotes/MaitreD"); + _states.load("States/MaitreD"); +} + +void MaitreDScript::setupSentences() { + _mappings.load("Mappings/MaitreD", 1); + _entries.load("Sentences/MaitreD"); + _sentences1.load("Sentences/MaitreD/1"); + _field68 = 0; + _entryCount = 0; +} + +int MaitreDScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) { + if (tag == MKTAG('F', 'O', 'O', 'D') || tag == MKTAG('F', 'I', 'S', 'H') || + tag == MKTAG('C', 'H', 'S', 'E')) { + addResponse(getDialogueId(260388)); + addResponse(getDialogueId(260659)); + applyResponse(); + return 2; + } + + return TTnpcScript::chooseResponse(roomScript, sentence, tag); +} + +int MaitreDScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + if (roomScript->_scriptId != 132) + return 2; + if (preprocess(roomScript, sentence) == 1) + return 1; + + CTrueTalkManager::setFlags(10, 0); + setState(0); + + if (getValue(12) == 0) { + trigger12(false); + _answerCtr = 0; + + if (sentence->contains("restaurant at the end of the universe") + || sentence->contains("milliway") + || sentence->contains("big bang burger bar")) { + addResponse(getDialogueId(260975)); + applyResponse(); + } else if (processEntries(&_entries, _entryCount, roomScript, sentence) == 2) { + // Do nothing further + } else if (sentence->localWord("menu")) { + addResponse(getDialogueId(260683)); + applyResponse(); + } else if (sentence->localWord("table") && sentence->localWord("other")) { + addResponse(getDialogueId(260091)); + applyResponse(); + } else if ((sentence->localWord("not") && sentence->localWord("busy")) + || (sentence->localWord("no") && sentence->localWord("people")) + || sentence->localWord("empty")) { + addResponse(getDialogueId(260087)); + applyResponse(); + } else if (!defaultProcess(roomScript, sentence) + && processEntries(&_sentences1, 0, roomScript, sentence) != 2 + && processEntries(_defaultEntries, 0, roomScript, sentence) != 2) { + addResponse(getDialogueId(260975)); + applyResponse(); + } + + return 2; + } + + if (++_answerCtr > 50 || sentence->localWord("stop") || sentence->localWord("enough") + || sentence->contains("i give up") || sentence->contains("i give in") + || sentence->contains("i surrender") || sentence->contains("i submit")) { + _answerCtr = 0; + trigger12(false); + addResponse(getDialogueId(260063)); + } else if (sentence->localWord("not") && sentence->localWord("fight") && + (sentence->localWord("feel") || sentence->localWord("want") + || sentence->localWord("do") || sentence->localWord("will"))) { + _answerCtr = 0; + trigger12(false); + addResponse(getDialogueId(260678)); + } else if (sentence->contains("touche") || sentence->contains("toushe")) { + addResponse(getDialogueId(260098)); + } else if (sentence->contains("have at you")) { + addResponse(getDialogueId(260047)); + } else if (sentence->contains("en garde") || sentence->contains("on guard")) { + addResponse(getDialogueId(260008)); + } else if ((sentence->localWord("surrender") && !sentence->contains("i surrender")) + || (sentence->contains("give up") && !sentence->contains("i give up")) + || (sentence->contains("give in") && !sentence->contains("i give in")) + || (sentence->contains("submit") && !sentence->contains("i submit"))) { + addResponse(getDialogueId(260086)); + } else { + addResponse(getDialogueId(260031)); + } + + applyResponse(); + return 2; +} + +ScriptChangedResult MaitreDScript::scriptChanged(const TTroomScript *roomScript, uint id) { + resetFlags(); + bool flag1 = false, flag2 = false; + + switch (id) { + case 3: + if (getValue(4)) + addResponse(getDialogueId(260655)); + else if (getValue(12)) + addResponse(getDialogueId(260622)); + else if (getValue(9) && getValue(16)) + addResponse(getDialogueId(getValue(16))); + else if (getValue(15)) + addResponse(getDialogueId(260649)); + else + addResponse(getDialogueId(260112)); + + CTrueTalkManager::setFlags(16, 0); + CTrueTalkManager::setFlags(15, 1); + applyResponse(); + break; + + case 110: + addResponse(getDialogueId(260118)); + applyResponse(); + trigger12(true); + CTrueTalkManager::setFlags(8, 1); + CTrueTalkManager::setFlags(9, 1); + break; + + case 111: + CTrueTalkManager::setFlags(16, 260680); + CTrueTalkManager::setFlags(8, 0); + CTrueTalkManager::setFlags(9, 1); + break; + + case 112: + addResponse(getDialogueId(getValue(8) ? 260095 : 260127)); + applyResponse(); + break; + + case 113: + CTrueTalkManager::setFlags(16, 260266); + CTrueTalkManager::setFlags(8, 0); + CTrueTalkManager::setFlags(9, 1); + break; + + case 114: + CTrueTalkManager::setFlags(16, 260267); + CTrueTalkManager::setFlags(8, 0); + CTrueTalkManager::setFlags(9, 1); + break; + + case 115: + CTrueTalkManager::setFlags(16, 260268); + CTrueTalkManager::setFlags(8, 0); + CTrueTalkManager::setFlags(9, 1); + break; + + case 116: + CTrueTalkManager::setFlags(8, 0); + CTrueTalkManager::setFlags(9, 1); + break; + + case 117: + CTrueTalkManager::setFlags(8, 0); + CTrueTalkManager::setFlags(9, 0); + setFlags12(); + break; + + case 132: + addResponse(getDialogueId(260655)); + applyResponse(); + break; + + default: + flag1 = true; + break; + } + + if (!getValue(8)) { + switch (id - 118) { + case 0: + addResponse(getDialogueId(260676)); + applyResponse(); + break; + case 1: + addResponse(getDialogueId(260677)); + applyResponse(); + break; + case 2: + addResponse(getDialogueId(260189)); + applyResponse(); + break; + case 3: + case 4: + case 5: + case 6: + case 7: + CTrueTalkManager::setFlags(13, id - 120); + break; + case 8: + CTrueTalkManager::setFlags(13, 0); + break; + case 9: + if (!getValue(12)) { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260120)); + applyResponse(); + } else if (getRandomNumber(4) == 1) { + addResponse(getDialogueId(260067)); + applyResponse(); + } else { + addResponse(getDialogueId(260131)); + applyResponse(); + } + break; + + case 10: + if (getValue(12) == 0) { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } else if (getRandomNumber(4) == 1) { + addResponse(getDialogueId(260077)); + applyResponse(); + } else { + addResponse(getDialogueId(260131)); + applyResponse(); + } + break; + + case 11: + if (getValue(12)) { + addResponse(getDialogueId(260121)); + applyResponse(); + } else { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } + break; + + case 12: + if (getValue(12)) { + addResponse(getDialogueId(260131)); + applyResponse(); + } else { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } + break; + + case 13: + setFlags12(); + addResponse(getDialogueId(260131)); + applyResponse(); + break; + + case 15: + CTrueTalkManager::setFlags(13, 1); + if (getValue(12)) { + addResponse(getDialogueId(260122)); + applyResponse(); + } else { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } + break; + + case 16: + CTrueTalkManager::setFlags(13, 2); + if (getValue(12)) { + addResponse(getDialogueId(260123)); + applyResponse(); + } else { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } + break; + + case 17: + CTrueTalkManager::setFlags(13, 3); + if (getValue(12)) { + addResponse(getDialogueId(260124)); + applyResponse(); + } else { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } + break; + + case 18: + CTrueTalkManager::setFlags(13, 4); + if (getValue(12)) { + addResponse(getDialogueId(260125)); + applyResponse(); + } else { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } + break; + + case 19: + CTrueTalkManager::setFlags(13, 5); + if (getValue(12)) { + addResponse(getDialogueId(260126)); + applyResponse(); + } else { + addResponse(getDialogueId(getValue(14) == 1 ? 260063 : 260119)); + applyResponse(); + } + break; + + default: + flag2 = true; + break; + } + } + + return !flag1 || !flag2 ? SCR_2 : SCR_0; +} + +int MaitreDScript::handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder) { + switch (tagId) { + case MKTAG('A', 'D', 'V', 'T'): + case MKTAG('A', 'R', 'T', 'I'): + case MKTAG('A', 'R', 'T', 'Y'): + case MKTAG('B', 'R', 'N', 'D'): + case MKTAG('C', 'O', 'M', 'D'): + case MKTAG('D', 'N', 'C', 'E'): + case MKTAG('H', 'B', 'B', 'Y'): + case MKTAG('L', 'I', 'T', 'R'): + case MKTAG('M', 'A', 'G', 'S'): + case MKTAG('M', 'C', 'P', 'Y'): + case MKTAG('M', 'I', 'N', 'S'): + case MKTAG('M', 'U', 'S', 'I'): + case MKTAG('N', 'I', 'K', 'E'): + case MKTAG('S', 'F', 'S', 'F'): + case MKTAG('S', 'O', 'A', 'P'): + case MKTAG('S', 'P', 'R', 'T'): + case MKTAG('S', 'O', 'N', 'G'): + case MKTAG('T', 'E', 'A', 'M'): + case MKTAG('T', 'V', 'S', 'H'): + case MKTAG('W', 'W', 'E', 'B'): + tagId = MKTAG('E', 'N', 'T', 'N'); + break; + case MKTAG('A', 'C', 'T', 'R'): + case MKTAG('A', 'C', 'T', 'S'): + case MKTAG('A', 'U', 'T', 'H'): + case MKTAG('B', 'A', 'R', 'K'): + case MKTAG('B', 'A', 'R', 'U'): + case MKTAG('B', 'L', 'F', '1'): + case MKTAG('B', 'L', 'F', '2'): + case MKTAG('B', 'L', 'P', '1'): + case MKTAG('B', 'L', 'P', '2'): + case MKTAG('B', 'L', 'P', '3'): + case MKTAG('B', 'L', 'P', '4'): + case MKTAG('B', 'L', 'R', '1'): + case MKTAG('B', 'L', 'R', '2'): + case MKTAG('B', 'L', 'T', '1'): + case MKTAG('B', 'L', 'T', '2'): + case MKTAG('B', 'L', 'T', '3'): + case MKTAG('B', 'L', 'T', '4'): + case MKTAG('B', 'L', 'T', '5'): + case MKTAG('C', 'O', 'P', 'S'): + case MKTAG('D', 'C', 'T', 'R'): + case MKTAG('F', 'A', 'M', 'E'): + case MKTAG('F', 'A', 'S', 'H'): + case MKTAG('G', 'I', 'R', 'L'): + case MKTAG('H', 'E', 'R', 'O'): + case MKTAG('H', 'O', 'S', 'T'): + case MKTAG('K', 'N', 'O', 'B'): + case MKTAG('N', 'H', 'R', 'O'): + case MKTAG('R', 'A', 'C', 'E'): + case MKTAG('S', 'C', 'I', 'T'): + case MKTAG('T', 'D', 'V', 'P'): + case MKTAG('T', 'W', 'A', 'T'): + case MKTAG('W', 'E', 'A', 'T'): + tagId = MKTAG('P', 'R', 'S', 'N'); + break; + case MKTAG('C', 'H', 'S', 'E'): + case MKTAG('C', 'M', 'N', 'T'): + case MKTAG('F', 'I', 'L', 'M'): + case MKTAG('L', 'I', 'Q', 'D'): + tagId = MKTAG('F', 'O', 'O', 'D'); + break; + case MKTAG('C', 'R', 'I', 'M'): + case MKTAG('C', 'S', 'P', 'Y'): + case MKTAG('D', 'R', 'U', 'G'): + tagId = MKTAG('V', 'B', 'A', 'D'); + break; + case MKTAG('E', 'A', 'R', 'T'): + case MKTAG('H', 'O', 'M', 'E'): + case MKTAG('N', 'P', 'L', 'C'): + case MKTAG('P', 'L', 'A', 'N'): + tagId = MKTAG('P', 'L', 'A', 'C'); + break; + case MKTAG('F', 'A', 'U', 'N'): + case MKTAG('F', 'I', 'S', 'H'): + case MKTAG('F', 'L', 'O', 'R'): + tagId = MKTAG('N', 'A', 'T', 'R'); + break; + case MKTAG('H', 'H', 'L', 'D'): + case MKTAG('T', 'O', 'Y', 'S'): + case MKTAG('W', 'E', 'A', 'P'): + tagId = MKTAG('M', 'A', 'C', 'H'); + break; + case MKTAG('M', 'L', 'T', 'Y'): + case MKTAG('P', 'G', 'R', 'P'): + case MKTAG('P', 'T', 'I', 'C'): + tagId = MKTAG('G', 'R', 'U', 'P'); + break; + case MKTAG('P', 'K', 'U', 'P'): + case MKTAG('S', 'E', 'X', '1'): + case MKTAG('S', 'W', 'E', 'R'): + tagId = MKTAG('R', 'U', 'D', 'E'); + break; + case MKTAG('P', 'H', 'I', 'L'): + case MKTAG('R', 'C', 'K', 'T'): + tagId = MKTAG('S', 'C', 'I', 'E'); + break; + case MKTAG('T', 'R', 'A', '2'): + case MKTAG('T', 'R', 'A', '3'): + tagId = MKTAG('T', 'R', 'A', 'V'); + break; + + } + + return TTnpcScript::handleQuote(roomScript, sentence, val, tagId, remainder); +} + +int MaitreDScript::updateState(uint oldId, uint newId, int index) { + if (getValue(8)) { + if (oldId == 260112) + return getRangeValue(260654); + if (oldId != 260655 && oldId != 260654) + return getRangeValue(260655); + } + + newId = getStateDialogueId(oldId, newId); + + if (newId == 260023) { + switch (getValue(13)) { + case 1: + newId = 260023; break; + case 2: + newId = 260024; break; + case 3: + newId = 260025; break; + case 4: + newId = 260026; break; + case 5: + newId = 260027; break; + default: + newId = 260016; break; + } + } + + if (newId == 260034) { + switch (getValue(13)) { + case 1: + newId = 260034; break; + case 2: + newId = 260035; break; + case 3: + newId = 260036; break; + case 4: + newId = 260037; break; + case 5: + newId = 260038; break; + default: + newId = 260045; break; + } + } + + if (newId == 260070) { + switch (getValue(13)) { + case 1: + newId = 260070; break; + case 2: + newId = 260071; break; + case 3: + newId = 260072; break; + case 4: + newId = 260073; break; + case 5: + newId = 260074; break; + default: + newId = 260110; break; + } + } + + if (newId == 260076 || newId == 260181 || newId == 261010) { + CTrueTalkManager::setFlags(14, 1); + trigger12(true); + setFlags10(newId, index); + return newId; + } + + if (!getValue(12)) { + static const uint FLAG_IDS[] = { + 260080, 260066, 260067, 260062, 260050, 260087, 260090, 260171, 260173, + 260184, 260193, 260202, 260205, 260220, 260221, 260223, 260231, 260232, + 260365, 260373, 260374, 260387, 260421, 260622, 260695, 0 + }; + + for (uint idx = 0; FLAG_IDS[idx]; ++idx) { + if (FLAG_IDS[idx] == newId) { + setFlags12(); + break; + } + } + } + + if (newId == 261018) { + if (getValue(8) == 0 && getValue(9) == 0) { + newId = getRangeValue(260961); + setFlags10(newId, index); + return newId; + } + + if (getValue(8) == 1 && getValue(9) == 1) { + newId = getRangeValue(260655); + setFlags10(newId, index); + return newId; + } + + if (getValue(9) && getValue(16)) { + newId = getValue(16); + setFlags10(newId, index); + return index; + } + + newId = 260989; + } + + setFlags10(newId, index); + return newId; +} + +int MaitreDScript::preResponse(uint id) { + if (id == 60911) + return 260101; + + return 0; +} + +uint MaitreDScript::getStateDialogueId(uint oldId, uint newId) { + if (getValue(8) || getValue(9)) + return newId; + + switch (newId) { + case 260009: + case 260010: + case 260011: + case 260012: + return getRangeValue(260961); + case 260052: + return 260094; + case 260203: + return 260204; + case 260211: + case 260212: + case 260761: + case 260986: + case 260987: + case 260989: + return getRangeValue(260961); + case 260263: + case 260264: + return 260265; + case 260411: + return 260457; + case 260427: + case 260053: + case 260054: + case 260055: + case 260056: + case 260057: + case 260058: + case 260059: + case 260060: + return 260135; + case 260698: + case 260895: + case 260896: + return 260457; + case 260799: + return 260214; + + default: + return newId; + } +} + + +void MaitreDScript::setFlags12() { + int val = getValue(12); + CTrueTalkManager::setFlags(12, 1); + + if (!val) { + CTrueTalkManager::triggerAction(8, 0); + resetRange(260121); + resetRange(260122); + resetRange(260123); + resetRange(260124); + resetRange(260125); + resetRange(260126); + } +} + +void MaitreDScript::setFlags10(uint newId, uint index) { + int val = 28; + for (uint idx = 0; idx < _states.size(); ++idx) { + TTmapEntry &us = _states[idx]; + if (us._src == newId) { + val = us._dest; + break; + } + } + + CTrueTalkManager::setFlags(10, val); +} + +void MaitreDScript::trigger12(bool flag) { + int val = getValue(12); + CTrueTalkManager::setFlags(12, 0); + + if (val) { + CTrueTalkManager::triggerAction(flag ? 10 : 9, 0); + } +} + +int MaitreDScript::preprocess(const TTroomScript *roomScript, const TTsentence *sentence) { + if (!roomScript || !sentence || getValue(8)) + return 1; + + bool stateFlag = true, applyFlag = false; + switch (getValue(10)) { + case 1: + if (!getValue(11) && !getValue(8)) { + addResponse(getDialogueId(260052)); + applyFlag = true; + stateFlag = false; + } + break; + + case 2: + if (sentence->localWord("change") || sentence->localWord("music")) { + addResponse(getDialogueId(200684)); + applyFlag = true; + } + break; + + case 3: + if (sentence->localWord("chance") && (sentence->localWord("another") + || sentence->localWord("other") || sentence->localWord("more"))) { + addResponse(getDialogueId(260106)); + } else { + addResponse(getDialogueId(260107)); + } + applyFlag = true; + break; + + case 4: + if (sentence->contains("unless what")) { + addResponse(getDialogueId(260099)); + } else { + addResponse(getDialogueId(260131)); + applyFlag = true; + stateFlag = false; + } + break; + + case 5: + addResponse(getDialogueId(260096)); + applyFlag = true; + stateFlag = false; + break; + + case 6: + addResponse(getDialogueId(260097)); + applyFlag = true; + stateFlag = false; + break; + + case 7: + if (sentence->_field2C == 12) { + addResponse(getDialogueId(260089)); + applyFlag = true; + stateFlag = false; + } else { + addResponse(getDialogueId(260094)); + applyFlag = true; + CTrueTalkManager::setFlags(11, 1); + } + break; + + case 8: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + trigger12(false); + addResponse(getDialogueId(260094)); + CTrueTalkManager::setFlags(11, 1); + } else { + setFlags12(); + addResponse(getDialogueId(260131)); + } + applyFlag = true; + break; + + case 9: + setFlags12(); + break; + + case 11: + if ((sentence->localWord("say") || sentence->localWord("talk")) || + sentence->localWord("you")) { + addResponse(getDialogueId(260216)); + applyFlag = true; + } + break; + + case 12: + if (sentence->localWord("why") && sentence->localWord("naughty")) { + addResponse(getDialogueId(260196)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("what") && sentence->localWord("his") + && sentence->localWord("name")) { + addResponse(getDialogueId(260197)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("i") && sentence->localWord("meet")) { + addResponse(getDialogueId(260198)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("i") && sentence->localWord("speak")) { + addResponse(getDialogueId(260206)); + applyFlag = true; + stateFlag = false; + } + break; + + case 13: + if (sentence->localWord("why") || sentence->localWord("please") + || sentence->contains("go on") || sentence->localWord("need") + || sentence->contains("got to") || sentence->localWord("must")) { + addResponse(getDialogueId(260199)); + applyFlag = true; + stateFlag = false; + } + break; + + case 14: + if (sentence->localWord("what") || sentence->localWord("why") + || sentence->localWord("kill")) { + addResponse(getDialogueId(260200)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("you") && sentence->localWord("kill")) { + addResponse(getDialogueId(260574)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("how") && sentence->localWord("kill")) { + addResponse(getDialogueId(260557)); + applyFlag = true; + stateFlag = false; + } + break; + + case 15: + if ((sentence->localWord("what") && sentence->localWord("way")) + || sentence->localWord("how")) { + addResponse(getDialogueId(260201)); + applyFlag = true; + stateFlag = false; + } + break; + + case 16: + addResponse(getDialogueId(sentence->_field2C == 11 ? 260209 : 260210)); + applyFlag = true; + stateFlag = false; + break; + + case 17: + if (sentence->localWord("what") && sentence->localWord("mean")) { + addResponse(getDialogueId(260222)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("laugh") && sentence->localWord("with") + && sentence->localWord("you")) { + addResponse(getDialogueId(260221)); + applyFlag = true; + stateFlag = false; + } else { + setFlags12(); + addResponse(getDialogueId(260221)); + applyFlag = true; + stateFlag = false; + } + break; + + case 18: + if (sentence->_field2C == 11) { + addResponse(getDialogueId(260232)); + applyFlag = true; + } else if (sentence->_field2C == 12) { + addResponse(getDialogueId(260231)); + applyFlag = true; + } else if (sentence->_field2C == 13) { + addResponse(getDialogueId(260444)); + addResponse(getDialogueId(260233)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("what") && sentence->localWord("happen")) { + addResponse(getDialogueId(260233)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why") && sentence->localWord("stressed")) { + addResponse(getDialogueId(260245)); + addResponse(getDialogueId(260233)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why")) { + addResponse(getDialogueId(260453)); + addResponse(getDialogueId(260233)); + applyFlag = true; + stateFlag = false; + } + break; + + case 19: + if ((sentence->localWord("what") && sentence->localWord("scral")) + || (sentence->localWord("what") && sentence->localWord("happen")) + || sentence->contains("go on") || sentence->contains("and then")) { + addResponse(getDialogueId(260234)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why") && sentence->localWord("stressed")) { + addResponse(getDialogueId(260245)); + addResponse(getDialogueId(260234)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why")) { + addResponse(getDialogueId(260276)); + addResponse(getDialogueId(260237)); + addResponse(getDialogueId(260234)); + applyFlag = true; + stateFlag = false; + } + break; + + case 20: + if ((sentence->localWord("what") && sentence->localWord("leovinus")) + || (sentence->localWord("what") && sentence->localWord("happen"))) { + addResponse(getDialogueId(260235)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("where") && sentence->localWord("leovinus")) { + addResponse(getDialogueId(260236)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why") && sentence->localWord("stressed")) { + addResponse(getDialogueId(260245)); + addResponse(getDialogueId(260235)); + applyFlag = true; + stateFlag = false; + } else { + addResponse(getDialogueId(260237)); + applyFlag = true; + stateFlag = false; + } + break; + + case 21: + case 22: + if (sentence->contains("cooking") + || (sentence->localWord("what") && sentence->localWord("mean"))) { + addResponse(getDialogueId(260238)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("where") && sentence->localWord("now")) { + addResponse(getDialogueId(260236)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why") && sentence->localWord("stressed")) { + addResponse(getDialogueId(260245)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why")) { + addResponse(getDialogueId(260239)); + applyFlag = true; + stateFlag = false; + } + break; + + case 23: + if (sentence->_field2C == 11) { + addResponse(getDialogueId(260237)); + applyFlag = true; + stateFlag = false; + } + break; + + case 24: + if ((sentence->localWord("can") && sentence->localWord("i") + && sentence->localWord("have")) + || (sentence->localWord("give") && sentence->localWord("me")) + || (sentence->localWord("i") && sentence->localWord("want")) + || (sentence->localWord("i") && sentence->localWord("need")) + ) { + addResponse(getDialogueId(260251)); + applyFlag = true; + } + + case 25: + if ((sentence->localWord("open") && sentence->localWord("it")) + || (sentence->localWord("how") && sentence->localWord("open")) + || (sentence->localWord("how") && sentence->localWord("get") && sentence->localWord("in")) + || (sentence->localWord("how") && sentence->localWord("change") && sentence->localWord("music")) + ) { + addResponse(getDialogueId(260253)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("where") && (sentence->localWord("it") + || sentence->localWord("that"))) { + addResponse(getDialogueId(260252)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("where") && sentence->localWord("key")) { + addResponse(getDialogueId(260254)); + applyFlag = true; + stateFlag = false; + } else if ((sentence->localWord("how") && sentence->localWord("work")) + || (sentence->localWord("what") && sentence->localWord("i") && sentence->localWord("do"))) { + addResponse(getDialogueId(260259)); + applyFlag = true; + stateFlag = false; + } + break; + + case 26: + if (sentence->localWord("where") && (sentence->localWord("key") + || sentence->localWord("it"))) { + addResponse(getDialogueId(260254)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("where") && (sentence->localWord("hand") + || sentence->localWord("that"))) { + addResponse(getDialogueId(260256)); + applyFlag = true; + stateFlag = false; + } else if (sentence->_field2C == 12) { + addResponse(getDialogueId(260255)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("why") && sentence->localWord("need")) { + addResponse(getDialogueId(260685)); + applyFlag = true; + stateFlag = false; + } + break; + + case 27: + if (sentence->localWord("where") && (sentence->localWord("that") + || sentence->localWord("it"))) { + addResponse(getDialogueId(260262)); + applyFlag = true; + } + break; + + case 28: + if (sentence->localWord("why")) { + addResponse(getDialogueId(260386)); + applyFlag = true; + stateFlag = false; + } else if (sentence->localWord("insist")) { + addResponse(getDialogueId(260387)); + applyFlag = true; + stateFlag = false; + } + break; + + case 29: + if (sentence->_field2C == 11) { + setFlags12(); + addResponse(getDialogueId(260131)); + } else { + addResponse(getDialogueId(260966)); + } + applyFlag = true; + break; + + case 30: + if (sentence->_field2C == 11 || sentence->_field2C == 13) { + addResponse(getDialogueId(260695)); + applyFlag = true; + } else if (sentence->_field2C == 12) { + addResponse(getDialogueId(260696)); + applyFlag = true; + } + break; + } + + if (applyFlag) + applyResponse(); + if (stateFlag) { + setState(0); + CTrueTalkManager::setFlags(10, 0); + } + + return applyFlag ? 2 : 1; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/maitred_script.h b/engines/titanic/true_talk/maitred_script.h new file mode 100644 index 0000000000..0472050d20 --- /dev/null +++ b/engines/titanic/true_talk/maitred_script.h @@ -0,0 +1,101 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_MAITRED_SCRIPT_H +#define TITANIC_MAITRED_SCRIPT_H + +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class MaitreDScript : public TTnpcScript { +private: + TTmapEntryArray _states; + TTsentenceEntries _sentences1; + int _answerCtr; +private: + /** + * Setup sentence data + */ + void setupSentences(); + + /** + * Alter dialogue Id based on current NPC state + */ + uint getStateDialogueId(uint oldId, uint newId); + + /** + * Sets flags 12 and resets some ranges + */ + void setFlags12(); + + /** + * Sets flags 10 to different values based on the passed + * dialogue Id + */ + void setFlags10(uint newId, uint index); + + /** + * Trigers 12 + */ + void trigger12(bool flag); + + /** + * Does preprocessing for the sentence + */ + int preprocess(const TTroomScript *roomScript, const TTsentence *sentence); +public: + MaitreDScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + virtual int handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_MAITRED_SCRIPT_H */ diff --git a/engines/titanic/true_talk/parrot_script.cpp b/engines/titanic/true_talk/parrot_script.cpp new file mode 100644 index 0000000000..b09e74505c --- /dev/null +++ b/engines/titanic/true_talk/parrot_script.cpp @@ -0,0 +1,110 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/parrot_script.h" +#include "titanic/titanic.h" + +namespace Titanic { + +ParrotScript::ParrotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7) { + + loadRanges("Ranges/Parrot"); + setupSentences(); +} + +void ParrotScript::setupSentences() { + _mappings.load("Mappings/Parrot", 1); + _entries.load("Sentences/Parrot"); + _field68 = 0; + _entryCount = 0; +} + +int ParrotScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) { + if (tag == MKTAG('B', 'Y', 'Z', 'A')) { + addResponse(getDialogueId(280246)); + applyResponse(); + return 2; + } else { + return 1; + } +} + +int ParrotScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + if (processEntries(roomScript, sentence) == 2) { + int tagId = g_vm->_trueTalkManager->_quotes.find(sentence->_normalizedLine); + if (!tagId || chooseResponse(roomScript, sentence, tagId) != 2) { + addResponse(getDialogueId(sentence->check2C() ? 280248 : 280235)); + applyResponse(); + } + } + + return 2; +} + +ScriptChangedResult ParrotScript::scriptChanged(const TTroomScript *roomScript, uint id) { + if (id >= 280000 && id <= 280276) { + if (id == 280258) { + if (CTrueTalkManager::_currentNPC) { + CGameObject *chicken; + if (CTrueTalkManager::_currentNPC->find("Chicken", &chicken, FIND_PET)) + id = 280147 - getRandomBit(); + } + + id = getDialogueId(id); + } else { + if ((id == 280146 || id == 280147) && CTrueTalkManager::_currentNPC) { + CGameObject *chicken; + if (CTrueTalkManager::_currentNPC->find("Chicken", &chicken, FIND_PET)) + id = 280142; + } + + addResponse(getDialogueId(id)); + if (id == 280192) + addResponse(getDialogueId(280222)); + applyResponse(); + } + } + + if (id >= 80000 && id <= 80244) { + if ((id == 80155 || id == 80156) && CTrueTalkManager::_currentNPC) { + CGameObject *chicken; + if (CTrueTalkManager::_currentNPC->find("Chicken", &chicken, FIND_PET)) + id = 80151; + } + + addResponse(id); + if (id == 80201) + addResponse(getDialogueId(280222)); + applyResponse(); + } + + return (id == 3) ? SCR_2 : SCR_1; +} + +int ParrotScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + return 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/parrot_script.h b/engines/titanic/true_talk/parrot_script.h new file mode 100644 index 0000000000..ec7bec7629 --- /dev/null +++ b/engines/titanic/true_talk/parrot_script.h @@ -0,0 +1,63 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_PARROT_SCRIPT_H +#define TITANIC_PARROT_SCRIPT_H + +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class ParrotScript : public TTnpcScript { +private: + /** + * Setup sentence data + */ + void setupSentences(); +public: + ParrotScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + /** + * Process a sentence fragment entry + */ + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PARROT_SCRIPT_H */ diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp new file mode 100644 index 0000000000..64e789a4b9 --- /dev/null +++ b/engines/titanic/true_talk/script_handler.cpp @@ -0,0 +1,148 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/script_handler.h" +#include "titanic/true_talk/tt_concept.h" +#include "titanic/true_talk/tt_sentence.h" +#include "titanic/true_talk/tt_parser.h" +#include "titanic/true_talk/tt_word.h" +#include "titanic/titanic.h" + +namespace Titanic { + +/*------------------------------------------------------------------------*/ + +CScriptHandler::CScriptHandler(CTitleEngine *owner, int val1, int val2) : + _owner(owner), _script(owner->_script), _resources(g_vm->_exeResources), + _parser(this), _field10(0), _inputCtr(0), + _concept1P(nullptr), _concept2P(nullptr), _concept3P(nullptr), + _concept4P(nullptr), _field30(0) { + g_vm->_scriptHandler = this; + g_vm->_script = _script; + g_vm->_exeResources.reset(this, val1, val2); + _vocab = new TTvocab(val2); +} + +CScriptHandler::~CScriptHandler() { + delete _vocab; + delete _concept1P; + delete _concept2P; + delete _concept3P; + delete _concept4P; +} + +ScriptChangedResult CScriptHandler::scriptChanged(TTroomScript *roomScript, TTnpcScript *npcScript, uint dialogueId) { + if (!npcScript || !roomScript) { + ++_inputCtr; + return SCR_5; + } + + ScriptChangedResult result = roomScript->notifyScript(npcScript, dialogueId); + if (result == SCR_1) + result = npcScript->notifyScript(roomScript, dialogueId); + + if (result != SCR_3 && result != SCR_4) + return result; + + ++_inputCtr; + delete _concept1P; + delete _concept2P; + delete _concept3P; + delete _concept4P; + _concept1P = nullptr; + _concept2P = nullptr; + _concept3P = nullptr; + _concept4P = nullptr; + + return result; +} + +int CScriptHandler::processInput(TTroomScript *roomScript, TTnpcScript *npcScript, + const TTstring &line) { + if (!roomScript || !line.isValid()) + return SS_5; + + TTsentence *sentence = new TTsentence(_inputCtr++, line, this, roomScript, npcScript); + int result = _parser.preprocess(sentence); + roomScript->scriptPreprocess(sentence); + npcScript->scriptPreprocess(sentence); + + int canProcess = 0; + if (result) { + sentence->setState(result); + if (roomScript->canRespond(npcScript, sentence, result)) { + canProcess = npcScript->chooseResponse(roomScript, sentence, result); + } + } + + if (canProcess == 0 || canProcess == 1) { + if (!_parser.findFrames(sentence)) { + if (roomScript->canProcess(npcScript, sentence) && npcScript) { + npcScript->process(roomScript, sentence); + } + } + } + + delete sentence; + return SS_VALID; +} + +SimpleFile *CScriptHandler::openResource(const CString &name) { + return _owner->open(name); +} + +void CScriptHandler::setParserConcept(TTconcept *newConcept, TTconcept *oldConcept) { + _parser.conceptChanged(newConcept, oldConcept); +} + +int CScriptHandler::setResponse(TTscriptBase *script, TTresponse *response) { + return _owner->setResponse(script, response); +} + +void CScriptHandler::handleWord(const TTstring *str) { + handleWord1(str); + handleWord2(str); +} + +void CScriptHandler::handleWord1(const TTstring *str) { + if (_concept2P) + delete _concept2P; + _concept2P = nullptr; + + if (str) { + TTword word(*str, WC_UNKNOWN, 0); + _concept2P = new TTconcept(&word); + } +} + +void CScriptHandler::handleWord2(const TTstring *str) { + if (_concept1P) + delete _concept1P; + _concept1P = nullptr; + + if (str) { + TTword word(*str, WC_UNKNOWN, 0); + _concept1P = new TTconcept(&word); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h new file mode 100644 index 0000000000..193c60f719 --- /dev/null +++ b/engines/titanic/true_talk/script_handler.h @@ -0,0 +1,89 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SCRIPT_HANDLER_H +#define TITANIC_SCRIPT_HANDLER_H + +#include "titanic/true_talk/tt_npc_script.h" +#include "titanic/true_talk/tt_parser.h" +#include "titanic/true_talk/tt_room_script.h" +#include "titanic/true_talk/tt_string.h" +#include "titanic/true_talk/tt_vocab.h" +#include "titanic/support/exe_resources.h" + +namespace Titanic { + +class CTitleEngine; +class CScriptHandler; + +class CScriptHandler { +private: + CTitleEngine *_owner; + CExeResources &_resources; + int _field10; + int _inputCtr; + int _field30; +private: + void handleWord1(const TTstring *str); + void handleWord2(const TTstring *str); +public: + TTparser _parser; + TTvocab *_vocab; + TTscriptBase *_script; + TTconcept *_concept1P; + TTconcept *_concept2P; + TTconcept *_concept3P; + TTconcept *_concept4P; +public: + CScriptHandler(CTitleEngine *owner, int val1, int val2); + ~CScriptHandler(); + + /** + * Set the character and room + */ + ScriptChangedResult scriptChanged(TTroomScript *roomScript, + TTnpcScript *npcScript, uint dialogueId); + + int processInput(TTroomScript *roomScript, TTnpcScript *npcScript, + const TTstring &line); + + /** + * Open a resource for access + */ + SimpleFile *openResource(const CString &name); + + /** + * Called when concept data is copied from one to another + */ + void setParserConcept(TTconcept *newConcept, TTconcept *oldConcept); + + /** + * Sets a conversation reponse + */ + int setResponse(TTscriptBase *script, TTresponse *response); + + void handleWord(const TTstring *str); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SCRIPT_HANDLER_H */ diff --git a/engines/titanic/true_talk/script_support.cpp b/engines/titanic/true_talk/script_support.cpp new file mode 100644 index 0000000000..c24e275827 --- /dev/null +++ b/engines/titanic/true_talk/script_support.cpp @@ -0,0 +1,226 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/script_support.h" +#include "titanic/titanic.h" + +namespace Titanic { + +int TTnpcScriptResponse::size() const { + for (int idx = 0; idx < 4; ++idx) { + if (_values[idx] == 0) + return idx; + } + + return 4; +} + +/*------------------------------------------------------------------------*/ + +TTscriptRange::TTscriptRange(uint id, const Common::Array<uint> &values, + bool isRandom, bool isSequential) : + _id(id), _nextP(nullptr) { + _mode = SF_NONE; + if (isRandom) + _mode = SF_RANDOM; + if (isSequential) + _mode = SF_SEQUENTIAL; + + for (uint idx = 0; idx < values.size(); ++idx) + _values.push_back(values[idx]); +} + +/*------------------------------------------------------------------------*/ + + +bool TTsentenceEntry::load(Common::SeekableReadStream *s) { + if (s->pos() >= s->size()) + return false; + + _field0 = s->readUint32LE(); + _field4 = s->readUint32LE(); + _string8 = readStringFromStream(s); + _fieldC = s->readUint32LE(); + _string10 = readStringFromStream(s); + _string14 = readStringFromStream(s); + _string18 = readStringFromStream(s); + _string1C = readStringFromStream(s); + _field20 = s->readUint32LE(); + _string24 = readStringFromStream(s); + _field28 = s->readUint32LE(); + _field2C = s->readUint32LE(); + _field30 = s->readUint32LE(); + + return true; +} + +/*------------------------------------------------------------------------*/ + +void TTsentenceEntries::load(const CString &resName) { + TTsentenceEntry entry; + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(resName); + + while (entry.load(r)) + push_back(entry); + + delete r; +} + +/*------------------------------------------------------------------------*/ + +TTscriptMapping::TTscriptMapping() : _id(0) { + Common::fill(&_values[0], &_values[8], 0); +} + +/*------------------------------------------------------------------------*/ + +void TTscriptMappings::load(const char *name, int valuesPerMapping) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + _valuesPerMapping = valuesPerMapping; + + while (r->pos() < r->size()) { + resize(size() + 1); + TTscriptMapping &m = (*this)[size() - 1]; + + m._id = r->readUint32LE(); + for (int idx = 0; idx < valuesPerMapping; ++idx) + m._values[idx] = r->readUint32LE(); + } + + delete r; +} + +/*------------------------------------------------------------------------*/ + +void TTtagMappings::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + uint src = r->readUint32LE(); + uint dest = r->readUint32LE(); + + push_back(TTtagMapping(src, dest)); + } + + delete r; +} + +/*------------------------------------------------------------------------*/ + +void TTwordEntries::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + TTwordEntry we; + we._id = r->readUint32LE(); + we._text = readStringFromStream(r); + + push_back(we); + } + + delete r; +} + +/*------------------------------------------------------------------------*/ + +void TThandleQuoteEntries::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + _tag1 = r->readUint32LE(); + _tag2 = r->readUint32LE(); + _rangeStart = r->readUint32LE(); + _rangeEnd = r->readUint32LE(); + + while (r->pos() < r->size()) { + TThandleQuoteEntry qe; + qe._index = r->readUint32LE(); + qe._tagId = r->readUint32LE(); + qe._dialogueId = r->readUint32LE(); + + push_back(qe); + } + + delete r; +} + +/*------------------------------------------------------------------------*/ + +void TTmapEntryArray::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + TTmapEntry us; + us._src = r->readUint32LE(); + us._dest = r->readUint32LE(); + + push_back(us); + } + + delete r; +} + +int TTmapEntryArray::find(uint id) const { + for (uint idx = 0; idx < size(); ++idx) { + const TTmapEntry &me = (*this)[idx]; + if (me._src == id) + return me._dest; + } + + return 0; +} + +/*------------------------------------------------------------------------*/ + +void TTupdateStateArray::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + TTupdateState us; + us._newId = r->readUint32LE(); + us._newValue = r->readUint32LE(); + us._dialBits = r->readUint32LE(); + + push_back(us); + } + + delete r; +} + +/*------------------------------------------------------------------------*/ + +void TTcommonPhraseArray::load(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + TTcommonPhrase cp; + cp._str = readStringFromStream(r); + cp._dialogueId = r->readUint32LE(); + cp._roomNum = r->readUint32LE(); + cp._val1 = r->readUint32LE(); + + push_back(cp); + } + + delete r; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/script_support.h b/engines/titanic/true_talk/script_support.h new file mode 100644 index 0000000000..a41673bd5c --- /dev/null +++ b/engines/titanic/true_talk/script_support.h @@ -0,0 +1,194 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SCRIPT_SUPPORT_H +#define TITANIC_SCRIPT_SUPPORT_H + +#include "titanic/support/simple_file.h" + +namespace Titanic { + +#define DIALS_ARRAY_COUNT 10 + +enum ScriptArrayFlag { SF_NONE = 0, SF_RANDOM = 1, SF_SEQUENTIAL = 2 }; + +struct RoomDialogueId { + uint _roomNum; + uint _dialogueId; +}; + +struct TTnpcScriptResponse { + uint _tag; + uint _values[4]; + + /** + * Returns the size of the values list plus 1 + */ + int size() const; +}; + +struct TTscriptRange { + uint _id; + Common::Array<uint> _values; + TTscriptRange *_nextP; + uint _priorIndex; + ScriptArrayFlag _mode; + + TTscriptRange() : _id(0), _nextP(nullptr), + _priorIndex(0), _mode(SF_NONE) {} + TTscriptRange(uint id, const Common::Array<uint> &values, bool isRandom, + bool isSequential); +}; + + +struct TTsentenceEntry { + int _field0; + int _field4; + CString _string8; + int _fieldC; + CString _string10; + CString _string14; + CString _string18; + CString _string1C; + int _field20; + CString _string24; + int _field28; + int _field2C; + int _field30; + + TTsentenceEntry() : _field0(0), _field4(0), _fieldC(0), + _field20(0), _field28(0), _field2C(0), _field30(0) {} + + /** + * Load an entry from the passed stream, and returns true + * if an entry was successfully loaded + */ + bool load(Common::SeekableReadStream *s); +}; + +class TTsentenceEntries : public Common::Array<TTsentenceEntry> { +public: + /** + * Load a list of entries from the specified resource + */ + void load(const CString &resName); +}; + +struct TTscriptMapping { + uint _id; + uint _values[8]; + + TTscriptMapping(); +}; + +class TTscriptMappings : public Common::Array<TTscriptMapping> { +public: + int _valuesPerMapping; + + void load(const char *name, int valuesPerMapping); +}; + +struct TTtagMapping { + uint _src, _dest; + TTtagMapping() : _src(0), _dest(0) {} + TTtagMapping(uint src, uint dest) : _src(src), _dest(dest) {} +}; + +class TTtagMappings : public Common::Array<TTtagMapping> { +public: + void load(const char *name); +}; + +struct TTwordEntry { + uint _id; + CString _text; + + TTwordEntry() : _id(0) {} +}; + +class TTwordEntries : public Common::Array<TTwordEntry> { +public: + void load(const char *name); +}; + +struct TThandleQuoteEntry { + uint _index; + uint _tagId; + uint _dialogueId; + + TThandleQuoteEntry() : _index(0), _tagId(0), _dialogueId(0) {} +}; + +class TThandleQuoteEntries : public Common::Array<TThandleQuoteEntry> { +public: + uint _tag1, _tag2; + uint _rangeStart, _rangeEnd; +public: + TThandleQuoteEntries() : _tag1(0), _tag2(0), _rangeStart(0), _rangeEnd(0) {} + void load(const char *name); +}; + +struct TTmapEntry { + uint _src; + uint _dest; + + TTmapEntry() : _src(0), _dest(0) {} +}; + +class TTmapEntryArray : public Common::Array<TTmapEntry> { +public: + void load(const char *name); + + /** + * Finds a record by Id, and returns it's associated value + */ + int find(uint id) const; +}; + +struct TTupdateState { + uint _newId; + uint _newValue; + uint _dialBits; + + TTupdateState() : _newId(0), _newValue(0), _dialBits(0) {} +}; + +class TTupdateStateArray : public Common::Array<TTupdateState> { +public: + void load(const char *name); +}; + +struct TTcommonPhrase { + CString _str; + uint _dialogueId; + uint _roomNum; + uint _val1; +}; + +class TTcommonPhraseArray : public Common::Array<TTcommonPhrase> { +public: + void load(const char *name); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_NPC_SCRIPT_H */ diff --git a/engines/titanic/true_talk/succubus_script.cpp b/engines/titanic/true_talk/succubus_script.cpp new file mode 100644 index 0000000000..db537c6470 --- /dev/null +++ b/engines/titanic/true_talk/succubus_script.cpp @@ -0,0 +1,237 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/succubus_script.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +SuccUBusScript::SuccUBusScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : + TTnpcScript(val1, charClass, v2, charName, v3, val2, v4, v5, v6, v7), + _isRoom101(false) { + + loadRanges("Ranges/SuccUBus"); + setupSentences(); +} + +void SuccUBusScript::setupSentences() { + _mappings.load("Mappings/SuccUBus", 1); + _entries.load("Sentences/SuccUBus"); + _field68 = 0; + _entryCount = 0; +} + +int SuccUBusScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) { + uint dialogueId = tag; + + switch (tag) { + case MKTAG('S', 'L', 'O', 'W'): + case MKTAG('T', 'H', 'R', 'T'): + dialogueId = 70021; + + case MKTAG('S', 'U', 'C', '1'): + dialogueId = getDialogueId(230009); + break; + + case MKTAG('S', 'U', 'C', '2'): + dialogueId = 70117; + break; + + case MKTAG('S', 'W', 'E', 'R'): + dialogueId = getRandomNumber(100) > 40 ? 70103 : getDialogueId(230030); + break; + + default: + break; + } + + if (dialogueId) { + addResponse(dialogueId); + applyResponse(); + return 2; + } else { + return 1; + } +} + +int SuccUBusScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + if (!CTrueTalkManager::getStateValue(1)) + return 2; + + if (roomScript && roomScript->_scriptId == 101) + _isRoom101 = true; + + int currState = getState(); + if (currState) { + int currMode = sentence->_field2C; + bool modeFlag1 = currMode == 11 || currMode == 13; + bool modeFlag2 = currMode == 12; + setState(0); + + switch (currState) { + case 1: + if (currMode == 3 || currMode == 10) + return setResponse(70050, 0); + break; + + case 2: + if (modeFlag1 || modeFlag2) + return setResponse(70070 + (getRandomBit() ? 254 : 0), 0); + break; + + case 3: + if (currMode == 3 || currMode == 10) + return setResponse(70074, 0); + break; + + case 4: + if (currMode == 4) + return setResponse(70077, 0); + if (currMode == 3) + return setResponse(getDialogueId(230117), 0); + break; + + case 5: + if (currMode == 3 || currMode == 10) + return setResponse(70089, 0); + break; + + case 6: + if (modeFlag1) + return setResponse(70103, 0); + if (modeFlag2) + return setResponse(70102, 0); + break; + + case 7: + if (modeFlag1) + return setResponse(getDialogueId(230157), 0); + break; + + case 8: + if (modeFlag1) + return setResponse(getDialogueId(230159), 0); + break; + + case 9: + if (modeFlag1) + return setResponse(getDialogueId(230160), 0); + break; + + case 10: + if (modeFlag1) + return setResponse(getDialogueId(230161), 0); + break; + + case 11: + if (modeFlag1) + return setResponse(getDialogueId(230142), 0); + break; + + case 12: + return setResponse(70030, 0); + + default: + break; + } + } + + if (processEntries(&_entries, _entryCount, roomScript, sentence) != 2) { + uint tagId = g_vm->_trueTalkManager->_quotes.find(sentence->_normalizedLine.c_str()); + if (tagId && chooseResponse(roomScript, sentence, tagId) != 2) { + addResponse(getDialogueId(230030)); + applyResponse(); + } + } + + return 2; +} + +ScriptChangedResult SuccUBusScript::scriptChanged(const TTroomScript *roomScript, uint id) { + if (id == 148) + CTrueTalkManager::setFlags(3, 1); + else if (id == 150) + CTrueTalkManager::setFlags(2, 1); + + if (id >= 230000 && id <= 230245) { + addResponse(getDialogueId(id)); + applyResponse(); + } + else if (id >= 70000 && id <= 70243) { + addResponse(id); + applyResponse(); + } + + return SCR_2; +} + +int SuccUBusScript::updateState(uint oldId, uint newId, int index) { + if (newId == 230199) { + return _isRoom101 ? 230148 : newId; + } else if (newId >= 230208 && newId <= 230235) { + addResponse(70158 - getRandomBit()); + return newId; + } else if (newId >= 230061 && newId <= 230063) { + if (getValue(2)) + return 230125; + } + + static const uint UPDATE_STATES[][2] = { + { 230078, 1 }, { 230106, 2 }, { 230112, 3 }, { 230115, 4 }, + { 230127, 5 }, { 230140, 6 }, { 230156, 7 }, { 230157, 8 }, + { 230159, 9 }, { 230160, 10 }, { 230161, 11 }, { 230072, 12 } + }; + + for (int idx = 0; idx < 12; ++idx) { + if (UPDATE_STATES[idx][0] == newId) { + setState(UPDATE_STATES[idx][1]); + break; + } + } + + return newId; +} + +int SuccUBusScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + if (val1 == 1 && roomScript && roomScript->_scriptId == 101) { + addResponse(getDialogueId(230239)); + applyResponse(); + return 2; + } + + return 0; +} + +int SuccUBusScript::setResponse(int dialogueId, int state) { + addResponse(dialogueId); + applyResponse(); + + if (state != -1) + setState(state); + + return 2; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/succubus_script.h b/engines/titanic/true_talk/succubus_script.h new file mode 100644 index 0000000000..d5cea7e66f --- /dev/null +++ b/engines/titanic/true_talk/succubus_script.h @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_SUCCUBUS_SCRIPT_H +#define TITANIC_SUCCUBUS_SCRIPT_H + +#include "titanic/true_talk/tt_npc_script.h" + +namespace Titanic { + +class SuccUBusScript : public TTnpcScript { +private: + bool _isRoom101; +private: + /** + * Setup sentence data + */ + void setupSentences(); + + /** + * Add a response and optionally set the state + */ + int setResponse(int dialogueId, int state = -1); +public: + SuccUBusScript(int val1, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Process a sentence fragment entry + */ + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_SUCCUBUS_SCRIPT_H */ diff --git a/engines/titanic/true_talk/title_engine.cpp b/engines/titanic/true_talk/title_engine.cpp new file mode 100644 index 0000000000..4dd45ba335 --- /dev/null +++ b/engines/titanic/true_talk/title_engine.cpp @@ -0,0 +1,83 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/title_engine.h" +#include "titanic/titanic.h" + +namespace Titanic { + +CTitleEngine::CTitleEngine() : _script(nullptr), _scriptHandler(nullptr) { +} + +CTitleEngine::~CTitleEngine() { + delete _script; + delete _scriptHandler; +} + +void CTitleEngine::setup(int val1, int val2) { + _script = new TTTitleScript(); + _scriptHandler = new CScriptHandler(this, val1, val2); +} + +/*------------------------------------------------------------------------*/ + +STtitleEngine::STtitleEngine(): CTitleEngine(), + _responseP(nullptr), _field58(0) { +} + +STtitleEngine::~STtitleEngine() { + delete _stream; +} + +void STtitleEngine::reset() { + _field58 = 0; + _indexes.clear(); +} + +void STtitleEngine::setup(int val1, int val2) { + CTitleEngine::setup(val1, 3); +} + +int STtitleEngine::setResponse(TTscriptBase *script, TTresponse *response) { + _indexes.clear(); + for (TTresponse *respP = response; respP; respP = respP->getNext()) { + _indexes.push_back(respP->getDialogueId()); + } + + return 0; +} + +void STtitleEngine::dump(int val1, int val2) { + // TODO +} + +SimpleFile *STtitleEngine::open(const CString &name) { + Common::SeekableReadStream *stream = g_vm->_filesManager->getResource( + CString::format("TEXT/%s", name.c_str())); + assert(stream); + + SimpleFile *file = new SimpleFile(); + file->open(stream); + return file; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/title_engine.h b/engines/titanic/true_talk/title_engine.h new file mode 100644 index 0000000000..afd2d3b92f --- /dev/null +++ b/engines/titanic/true_talk/title_engine.h @@ -0,0 +1,113 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TITLE_ENGINE_H +#define TITANIC_TITLE_ENGINE_H + +#include "common/stream.h" +#include "common/winexe_pe.h" +#include "titanic/support/string.h" +#include "titanic/true_talk/script_handler.h" +#include "titanic/true_talk/tt_response.h" +#include "titanic/true_talk/tt_script_base.h" +#include "titanic/true_talk/tt_title_script.h" + +namespace Titanic { + +class CTitleEngine; + +class CTitleStream : public SimpleFile { +public: + CTitleStream() : SimpleFile() {} +}; + +class CTitleEngine { +public: + CScriptHandler *_scriptHandler; + TTscriptBase *_script; +public: + CTitleEngine(); + virtual ~CTitleEngine(); + + /** + * Setup the engine + */ + virtual void setup(int val1, int val2 = 0); + + /** + * Sets a conversation reponse + */ + virtual int setResponse(TTscriptBase *script, TTresponse *response) { return SS_4; } + + virtual int proc4(int unused) const = 0; + virtual int proc5(int64 unused) const = 0; + virtual int proc6(int64 unused) const = 0; + virtual int proc7(int64 unused) const = 0; + virtual int proc8() const = 0; + + /** + * Open a designated file + */ + virtual SimpleFile *open(const CString &name) = 0; +}; + +class STtitleEngine : public CTitleEngine { +private: + Common::SeekableReadStream *_stream; + TTresponse *_responseP; + int _field58; +public: + Common::Array<uint> _indexes; + Common::Array<byte> _data; +public: + STtitleEngine(); + virtual ~STtitleEngine(); + + void reset(); + + /** + * Setup the engine + */ + virtual void setup(int val1, int val2 = 0); + + /** + * Sets a conversation reponse + */ + virtual int setResponse(TTscriptBase *script, TTresponse *response); + + virtual void dump(int val1, int val2); + + virtual int proc4(int unused) const { return 0; } + virtual int proc5(int64 unused) const { return 0; } + virtual int proc6(int64 unused) const { return 0; } + virtual int proc7(int64 unused) const { return 0; } + virtual int proc8() const { return 0; } + + /** + * Open a designated file + */ + virtual SimpleFile *open(const CString &name); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TITLE_ENGINE_H */ diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp new file mode 100644 index 0000000000..977edd5399 --- /dev/null +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -0,0 +1,597 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/core/tree_item.h" +#include "titanic/npcs/true_talk_npc.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" + +#define MKTAG_BE(a3,a2,a1,a0) ((uint32)((a3) | ((a2) << 8) | ((a1) << 16) | ((a0) << 24))) + +namespace Titanic { + +int CTrueTalkManager::_v1; +int CTrueTalkManager::_v2; +int CTrueTalkManager::_v3; +bool CTrueTalkManager::_v4; +bool CTrueTalkManager::_v5; +int CTrueTalkManager::_v6; +int CTrueTalkManager::_v7; +bool CTrueTalkManager::_v8; +int CTrueTalkManager::_v9; +bool CTrueTalkManager::_v10; +int CTrueTalkManager::_v11[41]; +CTrueTalkNPC *CTrueTalkManager::_currentNPC; + +/*------------------------------------------------------------------------*/ + +CTrueTalkManager::CTrueTalkManager(CGameManager *owner) : + _gameManager(owner), _scripts(&_titleEngine), _currentCharId(0), + _dialogueFile(nullptr), _dialogueId(0) { + _titleEngine.setup(3, 3); + _quotes.load(); + _quotesTree.load(); + + _currentNPC = nullptr; + g_vm->_trueTalkManager = this; +} + +CTrueTalkManager::~CTrueTalkManager() { + clear(); + g_vm->_trueTalkManager = nullptr; +} + +void CTrueTalkManager::save(SimpleFile *file) const { + saveStatics(file); + + saveNPC(file, 101); + saveNPC(file, 103); + saveNPC(file, 104); + saveNPC(file, 105); + saveNPC(file, 111); + saveNPC(file, 100); + saveNPC(file, 112); + saveNPC(file, 107); + file->writeNumber(0); +} + +void CTrueTalkManager::load(SimpleFile *file) { + loadStatics(file); + + // Iterate through loading characters + int charId = file->readNumber(); + while (charId) { + loadNPC(file, charId); + + int ident1 = file->readNumber(); + int ident2 = file->readNumber(); + + if (ident1 != MKTAG_BE('U', 'R', 'A', 'H')) { + while (ident2 != MKTAG_BE('A', 'K', 'E', 'R')) { + ident1 = ident2; + ident2 = file->readNumber(); + + if (!ident1) + break; + } + } + + // Get start of next character + charId = file->readNumber(); + } +} + +void CTrueTalkManager::loadStatics(SimpleFile *file) { + int count = file->readNumber(); + _v1 = file->readNumber(); + _v2 = file->readNumber(); + _v3 = file->readNumber(); + _v4 = file->readNumber() != 0; + _v5 = file->readNumber() != 0; + _v6 = file->readNumber(); + _v7 = file->readNumber(); + _v8 = file->readNumber() != 0; + _v9 = file->readNumber(); + _v10 = file->readNumber() != 0; + + for (int idx = count; count > 10; --idx) + file->readNumber(); + + int count2 = file->readNumber(); + for (int idx = 0; idx < count2; ++idx) { + int v = file->readNumber(); + if (idx < 41) + _v11[idx] = v; + } +} + +void CTrueTalkManager::saveStatics(SimpleFile *file) { + file->writeNumber(10); + file->writeNumber(_v1); + file->writeNumber(_v2); + file->writeNumber(_v3); + file->writeNumber(_v4 ? 1 : 0); + file->writeNumber(_v5 ? 1 : 0); + file->writeNumber(_v6); + file->writeNumber(_v7); + file->writeNumber(_v8 ? 1 : 0); + file->writeNumber(_v9); + file->writeNumber(_v10 ? 1 : 0); + + file->writeNumber(41); + for (int idx = 0; idx < 41; ++idx) + file->writeNumber(_v11[idx]); +} + +void CTrueTalkManager::clear() { + delete _dialogueFile; + _dialogueFile = nullptr; + _currentCharId = 0; +} + +void CTrueTalkManager::setFlags(int index, int val) { + switch (index) { + case 1: + if (val >= 1 && val <= 3) + _v3 = val; + break; + + case 2: + _v4 = !val; + break; + + case 3: + _v5 = val != 0; + break; + + case 4: + if (val >= 0 && val <= 3) + _v6 = val; + break; + + case 5: + _v7 = val; + break; + + case 6: + _v8 = val != 0; + break; + + default: + if (index < 41) + _v11[index] = val; + break; + } +} + +void CTrueTalkManager::loadNPC(SimpleFile *file, int charId) { + TTnpcScript *script = _scripts.getNpcScript(charId); + if (script) + script->load(file); +} + +void CTrueTalkManager::saveNPC(SimpleFile *file, int charId) const { + TTnpcScript *script = _scripts.getNpcScript(charId); + if (script) { + script->save(file); + file->writeNumber(MKTAG_BE('U', 'R', 'A', 'H')); + file->writeNumber(MKTAG_BE('A', 'K', 'E', 'R')); + } +} + +void CTrueTalkManager::preLoad() { + // Delete any previous talkers + for (TTtalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ++i) + delete *i; + _talkers.clear(); +} + +void CTrueTalkManager::removeCompleted() { + for (TTtalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ) { + TTtalker *talker = *i; + + if (talker->_done) { + i = _talkers.erase(i); + delete talker; + } else { + ++i; + } + } +} + +void CTrueTalkManager::update2() { + //warning("CTrueTalkManager::update2"); +} + +void CTrueTalkManager::start(CTrueTalkNPC *npc, uint id, CViewItem *view) { + TTnpcScript *npcScript = getNpcScript(npc); + TTroomScript *roomScript = getRoomScript(); + + _titleEngine.reset(); + uint charId = npcScript->charId(); + loadAssets(npc, charId); + + _currentNPC = npc; + _titleEngine._scriptHandler->scriptChanged(roomScript, npcScript, id); + _currentNPC = nullptr; + + setDialogue(npc, roomScript, view); +} + +void CTrueTalkManager::start3(CTrueTalkNPC *npc, CViewItem *view) { + start(npc, 3, view); +} + +void CTrueTalkManager::start4(CTrueTalkNPC *npc, CViewItem *view) { + start(npc, 4, view); +} + +TTnpcScript *CTrueTalkManager::getTalker(const CString &name) const { + if (name.contains("Doorbot")) + return _scripts.getNpcScript(104); + else if (name.contains("DeskBot")) + return _scripts.getNpcScript(103); + else if (name.contains("LiftBot")) + return _scripts.getNpcScript(105); + else if (name.contains("Parrot")) + return _scripts.getNpcScript(107); + else if (name.contains("BarBot")) + return _scripts.getNpcScript(100); + else if (name.contains("ChatterBot")) + return _scripts.getNpcScript(102); + else if (name.contains("BellBot")) + return _scripts.getNpcScript(101); + else if (name.contains("MaitreD")) + return _scripts.getNpcScript(112); + else if (name.contains("Succubus") || name.contains("Sub")) + return _scripts.getNpcScript(111); + + return nullptr; +} + +TTnpcScript *CTrueTalkManager::getNpcScript(CTrueTalkNPC *npc) const { + CString npcName = npc->getName(); + TTnpcScript *script = getTalker(npcName); + + if (!script) { + // Fall back on the default NPC script + script = _scripts.getNpcScript(101); + } + + return script; +} + +TTroomScript *CTrueTalkManager::getRoomScript() const { + CRoomItem *room = _gameManager->getRoom(); + TTroomScript *script = nullptr; + if (room) { + int scriptId = room->getScriptId(); + if (scriptId) + script = _scripts.getRoomScript(scriptId); + } + + if (!script) { + // Fall back on the default Room script + script = _scripts.getRoomScript(110); + } + + return script; +} + +TTroomScript *CTrueTalkManager::getRoomScript(int roomId) const { + TTroomScript *script = nullptr; + if (roomId) + script = _scripts.getRoomScript(roomId); + + if (!script) + // Fall back on the default Room script + script = _scripts.getRoomScript(110); + + return script; +} + +void CTrueTalkManager::loadAssets(CTrueTalkNPC *npc, int charId) { + // If assets for the character are already loaded, simply exit + if (_currentCharId == charId) + return; + + // Clear any previously loaded data + clear(); + + // Signal the NPC to get the asset details + CTrueTalkGetAssetDetailsMsg detailsMsg; + detailsMsg.execute(npc); + + if (!detailsMsg._filename.empty()) { + _dialogueFile = new CDialogueFile(detailsMsg._filename, 20); + _dialogueId = detailsMsg._numValue + 1; + } +} + +void CTrueTalkManager::processInput(CTrueTalkNPC *npc, CTextInputMsg *msg, CViewItem *view) { + TTnpcScript *npcScript = getNpcScript(npc); + TTroomScript *roomScript = getRoomScript(); + _titleEngine.reset(); + + if (npcScript && roomScript) { + _currentNPC = npc; + _titleEngine._scriptHandler->processInput(roomScript, npcScript, TTstring(msg->_input)); + _currentNPC = nullptr; + + loadAssets(npc, npcScript->charId()); + setDialogue(npc, roomScript, view); + } + + _currentNPC = nullptr; +} + +void CTrueTalkManager::setDialogue(CTrueTalkNPC *npc, TTroomScript *roomScript, CViewItem *view) { + // Get the dialog text + CString dialogueStr = readDialogueString(); + if (dialogueStr.empty()) + return; + + int soundId = readDialogSound(); + TTtalker *talker = new TTtalker(this, npc); + _talkers.push_back(talker); + + bool isParrot = npc->getName().contains("parrot"); + triggerNPC(npc); + playSpeech(talker, roomScript, view, isParrot); + talker->speechStarted(dialogueStr, _titleEngine._indexes[0], soundId); +} + +#define STRING_BUFFER_SIZE 2048 + +CString CTrueTalkManager::readDialogueString() { + byte buffer[STRING_BUFFER_SIZE]; + CString result; + + for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) { + if (idx != 0) + result += " "; + + // Open a text entry from the dialogue file for access + DialogueResource *textRes = _dialogueFile->openTextEntry( + _titleEngine._indexes[idx] - _dialogueId); + if (!textRes) + continue; + + size_t entrySize = textRes->size(); + byte *tempBuffer = (entrySize < STRING_BUFFER_SIZE) ? buffer : + new byte[entrySize + 1]; + + _dialogueFile->read(textRes, tempBuffer, entrySize); + buffer[entrySize] = '\0'; + + // Close the resource + _dialogueFile->closeEntry(textRes); + + // Strip off any non-printable characters + for (byte *p = buffer; *p != '\0'; ++p) { + if (*p < 32 || *p > 127) + *p = ' '; + } + + // Add string to result + result += CString((const char *)buffer); + + // Free buffer if one was allocated + if (entrySize >= STRING_BUFFER_SIZE) + delete[] tempBuffer; + } + + return result; +} + +int CTrueTalkManager::readDialogSound() { + _field18 = 0; + + for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) { + CWaveFile *waveFile = _gameManager->_sound.getTrueTalkSound( + _dialogueFile, _titleEngine._indexes[idx] - _dialogueId); + if (waveFile) { + _field18 = waveFile->fn1(); + } + } + + return _field18; +} + +void CTrueTalkManager::triggerNPC(CTrueTalkNPC *npc) { + CTrueTalkSelfQueueAnimSetMsg queueSetMsg; + if (queueSetMsg.execute(npc)) { + if (_field18 > 300) { + CTrueTalkQueueUpAnimSetMsg upMsg(_field18); + upMsg.execute(npc); + } + } else { + CTrueTalkGetAnimSetMsg getAnimMsg; + if (_field18 > 300) { + do { + getAnimMsg.execute(npc); + if (!getAnimMsg._endFrame) + break; + + npc->playMovie(getAnimMsg._startFrame, getAnimMsg._endFrame, 0); + getAnimMsg._endFrame = 0; + + uint numFrames = getAnimMsg._endFrame - getAnimMsg._startFrame; + int64 val = (numFrames * 1000) * 0x88888889; + uint diff = (val >> (32 + 5)) - 500; + _field18 += diff; + + getAnimMsg._index++; + } while (_field18 > 0); + } + } +} + +void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot) { + uint milli, index; + switch (roomScript->_scriptId) { + case 101: + milli = 300; + index = 16; + break; + case 106: + case 107: + case 110: + case 114: + case 115: + case 122: + milli = 130; + index = 10; + break; + case 108: + case 109: + milli = 200; + index = 10; + break; + case 111: + case 116: + case 121: + milli = 80; + index = 12; + break; + case 112: + case 124: + case 128: + case 130: + milli = 80; + index = 4; + break; + case 132: + milli = 60; + index = 4; + break; + default: + milli = 0; + index = 4; + break; + } + + // Setup proximities + CProximity p1, p2, p3; + if (isParrot) { + p1._channel = 3; + p2._channel = 5; + p3._channel = 4; + } else { + p1._channel = 0; + p2._channel = 1; + p3._channel = 2; + } + + if (milli > 0) { + p3._channelVolume = (index * 3) / 2; + p3._positioningMode = POSMODE_POLAR; + p3._azimuth = -135.0; + p3._range = 1.0; + p3._elevation = 0; + + p2._channelVolume = (index * 3) / 4; + p2._positioningMode = POSMODE_NONE; + p2._azimuth = 135.0; + p2._range = 1.0; + p2._elevation = 0; + } + + _gameManager->_sound.stopChannel(p1._channel); + if (view) { + p1._positioningMode = POSMODE_VECTOR; + view->getPosition(p1._posX, p1._posY, p1._posZ); + } + + // Loop through adding each of the speech portions in. We use the + // _priorSoundHandle of CProximity to chain each successive speech + // to start when the prior one finishes + for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) { + uint id = _titleEngine._indexes[idx]; + if (id > 100000) + continue; + + if (idx == (_titleEngine._indexes.size() - 1)) { + // Final iteration of speech segments to play + p1._endTalkerFn = &talkerEnd; + p1._talker = talker; + } + + // Start the speech + p1._priorSoundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p1); + if (!milli) + continue; + + if (idx == 0) + g_vm->_events->sleep(milli); + + p3._priorSoundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p3); + if (idx == 0) + g_vm->_events->sleep(milli); + + p2._priorSoundHandle = _gameManager->_sound.playSpeech(_dialogueFile, id - _dialogueId, p2); + } +} + +int CTrueTalkManager::getStateValue(int stateNum) { + if (!_currentNPC) + return -1000; + + CTrueTalkGetStateValueMsg msg(stateNum, -1000); + msg.execute(_currentNPC); + return msg._stateVal; +} + +bool CTrueTalkManager::triggerAction(int action, int param) { + if (!_currentNPC) + return false; + + CTrueTalkTriggerActionMsg msg(action, param, 0); + msg.execute(_currentNPC); + return true; +} + +void CTrueTalkManager::talkerEnd(TTtalker *talker) { + if (talker) + talker->endSpeech(0); +} + +CGameManager *CTrueTalkManager::getGameManager() const { + return _gameManager; +} + +CGameState *CTrueTalkManager::getGameState() const { + return _gameManager ? &_gameManager->_gameState : nullptr; +} + +int CTrueTalkManager::getPassengerClass() const { + CGameState *gameState = getGameState(); + return gameState ? gameState->_passengerClass : 4; +} + +int CTrueTalkManager::getState14() const { + CGameState *gameState = getGameState(); + return gameState ? gameState->_field14 : 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h new file mode 100644 index 0000000000..8a8895917a --- /dev/null +++ b/engines/titanic/true_talk/true_talk_manager.h @@ -0,0 +1,245 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TRUE_TALK_MANAGER_H +#define TITANIC_TRUE_TALK_MANAGER_H + +#include "titanic/messages/messages.h" +#include "titanic/support/simple_file.h" +#include "titanic/true_talk/dialogue_file.h" +#include "titanic/true_talk/title_engine.h" +#include "titanic/true_talk/tt_quotes.h" +#include "titanic/true_talk/tt_quotes_tree.h" +#include "titanic/true_talk/tt_scripts.h" +#include "titanic/true_talk/tt_talker.h" + +namespace Titanic { + +class CGameManager; +class CGameState; +class CTreeItem; +class CViewItem; +class CTrueTalkManager; +class CTrueTalkNPC; + +class CTrueTalkManager { +private: + CGameManager *_gameManager; + STtitleEngine _titleEngine; + TTscripts _scripts; + int _currentCharId; + CDialogueFile *_dialogueFile; + int _dialogueId; + int _field18; + TTtalkerList _talkers; +private: + /** + * Loads the statics for the class + */ + static void loadStatics(SimpleFile *file); + + /** + * Saves the statics associated with the class + */ + static void saveStatics(SimpleFile *file); + + /** + * Loads an NPC from file + */ + void loadNPC(SimpleFile *file, int charId); + + /** + * Saves the specified NPC to file + */ + void saveNPC(SimpleFile *file, int charId) const; + + /** + * Gets the script associated with an NPC game object + */ + TTnpcScript *getNpcScript(CTrueTalkNPC *npc) const; + + /** + * Gets the script associated with the current room + */ + TTroomScript *getRoomScript() const; + + /** + * Loads assets for the current character, if it's changed + */ + void loadAssets(CTrueTalkNPC *npc, int charId); + + void setDialogue(CTrueTalkNPC *npc, TTroomScript *roomScript, CViewItem *view); + + /** + * Read in text from the dialogue file + */ + CString readDialogueString(); + + /** + * Read in the sound from the dialogue file + */ + int readDialogSound(); + + /** + * Triggers animation for the NPC + */ + void triggerNPC(CTrueTalkNPC *npc); + + /** + * Plays speech specified by the manager's indexes array + */ + void playSpeech(TTtalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot); + + /** + * Called when a talker finishes + */ + static void talkerEnd(TTtalker *talker); + + /** + * Return the game state + */ + CGameState *getGameState() const; +public: + static int _v1; + static int _v2; + static int _v3; + static bool _v4; + static bool _v5; + static int _v6; + static int _v7; + static bool _v8; + static int _v9; + static bool _v10; + static int _v11[41]; + static CTrueTalkNPC *_currentNPC; + + static void setFlags(int index, int val); +public: + TTquotes _quotes; + TTquotesTree _quotesTree; +public: + /** + * Get a specified state value from the currently set NPC + */ + static int getStateValue(int stateNum); + + /** + * Trigger an NPC action + */ + static bool triggerAction(int action, int param); +public: + CTrueTalkManager(CGameManager *owner); + ~CTrueTalkManager(); + + /** + * Save the data for the class to file + */ + void save(SimpleFile *file) const; + + /** + * Load the data for the class from file + */ + void load(SimpleFile *file); + + /** + * Clear the manager + */ + void clear(); + + /** + * Called when a game is about to be loaded + */ + void preLoad(); + + /** + * Called when loading a game is complete + */ + void postLoad() {} + + /** + * Called when a game is about to be saved + */ + void preSave() {} + + /** + * Called when a game has finished being saved + */ + void postSave() {} + + /** + * Returns the scripts for the manager + */ + TTscripts &getScripts() { return _scripts; } + + /** + * Remove any completed talkers + */ + void removeCompleted(); + + /** + * Return the game manager + */ + CGameManager *getGameManager() const; + + void update2(); + + /** + * Start a TrueTalk conversation + */ + void start(CTrueTalkNPC *npc, uint id, CViewItem *view); + + /** + * Start a TrueTalk conversation + */ + void start3(CTrueTalkNPC *npc, CViewItem *view); + + /** + * Start a TrueTalk conversation + */ + void start4(CTrueTalkNPC *npc, CViewItem *view); + + /** + * Return a TrueTalk talker/script + */ + TTnpcScript *getTalker(const CString &name) const; + + /** + * Process player's input + */ + void processInput(CTrueTalkNPC *npc, CTextInputMsg *msg, CViewItem *view); + + /** + * Gets the script associated with a specific room + */ + TTroomScript *getRoomScript(int roomId) const; + + /** + * Get the player's passenger class + */ + int getPassengerClass() const; + + int getState14() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TRUE_TALK_MANAGER_H */ diff --git a/engines/titanic/true_talk/tt_action.cpp b/engines/titanic/true_talk/tt_action.cpp new file mode 100644 index 0000000000..5bf91c71df --- /dev/null +++ b/engines/titanic/true_talk/tt_action.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_action.h" + +namespace Titanic { + +bool TTaction::_staticFlag; + +TTaction::TTaction(const TTstring &str, WordClass wordClass, int val2, int val3, int val4) : + TTmajorWord(str, wordClass, val2, val3), _field30(val4) { +} + +TTaction::TTaction(const TTaction *src) : TTmajorWord(src) { + if (src->getStatus()) { + _field30 = 0; + _status = SS_5; + } else { + _field30 = src->_field30; + } +} + +int TTaction::load(SimpleFile *file) { + int val; + + if (!TTword::load(file, WC_ACTION) && file->scanf("%d", &val)) { + _field30 = val; + return 0; + } else { + return 8; + } +} + +TTword *TTaction::copy() const { + TTaction *returnWordP = new TTaction(this); + returnWordP->_status = _status; + if (!_status) { + _staticFlag = false; + return returnWordP; + } else if (_status == SS_13 && !_staticFlag) { + _staticFlag = true; + delete returnWordP; + return copy(); + } else { + delete returnWordP; + return nullptr; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_action.h b/engines/titanic/true_talk/tt_action.h new file mode 100644 index 0000000000..29e2bc4e4a --- /dev/null +++ b/engines/titanic/true_talk/tt_action.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_ACTION_H +#define TITANIC_TT_ACTION_H + +#include "titanic/true_talk/tt_major_word.h" + +namespace Titanic { + +class TTaction : public TTmajorWord { +private: + static bool _staticFlag; +protected: + int _field30; +public: + TTaction(const TTstring &str, WordClass wordClass, int val2, int val3, int val4); + TTaction(const TTaction *src); + + /** + * Load the word + */ + int load(SimpleFile *file); + + void setVal(int val) { _field30 = val; } + int getVal() const { return _field30; } + + /** + * Creates a copy of the word + */ + virtual TTword *copy() const; + + virtual bool proc12(int val) const { return _field30 == val; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_ACTION_H */ diff --git a/engines/titanic/true_talk/tt_adj.cpp b/engines/titanic/true_talk/tt_adj.cpp new file mode 100644 index 0000000000..a14784798f --- /dev/null +++ b/engines/titanic/true_talk/tt_adj.cpp @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_adj.h" + +namespace Titanic { + +bool TTadj::_staticFlag; + +TTadj::TTadj(TTstring &str, WordClass wordClass, int val2, int val3, int val4) : + TTmajorWord(str, wordClass, val2, val3) { + if (val4 >= 0 && val4 <= 9) { + _val = val4; + } else { + _val = 0; + _status = SS_5; + } +} + +TTadj::TTadj(const TTadj *src) : TTmajorWord(src) { + if (src->getStatus()) { + _val = 0; + _status = SS_5; + } else { + _val = src->_val; + } +} + +int TTadj::load(SimpleFile *file) { + int val; + + if (!TTword::load(file, WC_ADJECTIVE) && file->scanf("%d", &val)) { + _val = val; + return 0; + } else { + return 8; + } +} + +int TTadj::adjFn1(int val) { + if (_val < 0 || _val > 9) { + return SS_4; + } else { + _val = val; + return SS_VALID; + } +} + +TTword *TTadj::copy() const { + TTadj *returnWordP = new TTadj(this); + returnWordP->_status = _status; + if (!_status) { + _staticFlag = false; + return returnWordP; + } else if (_status == SS_13 && !_staticFlag) { + _staticFlag = true; + delete returnWordP; + return copy(); + } else { + delete returnWordP; + return nullptr; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_adj.h b/engines/titanic/true_talk/tt_adj.h new file mode 100644 index 0000000000..1dec8a77d2 --- /dev/null +++ b/engines/titanic/true_talk/tt_adj.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_ADJ_H +#define TITANIC_TT_ADJ_H + +#include "titanic/true_talk/tt_major_word.h" + +namespace Titanic { + +class TTadj : public TTmajorWord { +private: + static bool _staticFlag; +protected: + int _val; +public: + TTadj(TTstring &str, WordClass wordClass, int val2, int val3, int val4); + TTadj(const TTadj *src); + + /** + * Load the word + */ + int load(SimpleFile *file); + + int adjFn1(int val); + + /** + * Creates a copy of the word + */ + virtual TTword *copy() const; + + virtual bool proc14(int val) const { return _val == val; } + virtual int proc15() const { return _val; } + virtual bool proc16() const { return _val >= 7; } + virtual bool proc17() const { return _val <= 3; } + virtual bool proc18() const { return _val > 3 && _val < 7; } + + /** + * Dumps data associated with the word to file + */ + virtual int save(SimpleFile *file) const { + return saveData(file, _val); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_ADJ_H */ diff --git a/engines/titanic/true_talk/tt_concept.cpp b/engines/titanic/true_talk/tt_concept.cpp new file mode 100644 index 0000000000..c614e14dae --- /dev/null +++ b/engines/titanic/true_talk/tt_concept.cpp @@ -0,0 +1,308 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_concept.h" +#include "titanic/true_talk/tt_script_base.h" +#include "titanic/true_talk/tt_word.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTconcept::TTconcept() : _string1(" "), _string2(" "), + _scriptP(nullptr), _wordP(nullptr) { + if (setStatus()) + setScriptType(ST_UNKNOWN_SCRIPT); + else + reset(); +} + +TTconcept::TTconcept(TTscriptBase *script, ScriptType scriptType) : + _string1(" "), _string2(" "), _wordP(nullptr), _scriptP(nullptr) { + if (!script->getStatus()) { + setScriptType(scriptType); + _scriptP = script; + + if (scriptType == ST_UNKNOWN_SCRIPT && script->_id == 1) + _scriptType = ST_ROOM_SCRIPT; + } + + if (_status) + reset(); +} + +TTconcept::TTconcept(TTword *word, ScriptType scriptType) : + _string1(" "), _string2(" "), _wordP(nullptr), _scriptP(nullptr) { + + if (!word || !setStatus() || word->getStatus()) { + _status = SS_5; + } else { + _status = initializeWordRef(word); + if (!_status) + setScriptType(scriptType); + } + + if (_status) + reset(); +} + +TTconcept::TTconcept(TTconcept &src) : + _string1(src._string1), _string2(src._string2), + _wordP(nullptr), _scriptP(nullptr) { + + if (src.getStatus()) { + _status = SS_5; + } else { + if (setStatus()) { + _status = SS_VALID; + _scriptP = src._scriptP; + + if (src._wordP) { + _status = initializeWordRef(src._wordP); + initialize(src); + } + } + } + + if (_status) + reset(); +} + +TTconcept::~TTconcept() { + if (_word2P) { + _word2P->deleteSiblings(); + delete _word2P; + } + delete _wordP; + + if (_flag) + g_vm->_exeResources._owner->setParserConcept(this, nullptr); +} + +void TTconcept::deleteSiblings() { + for (TTconcept *currP = _nextP, *nextP; currP; currP = nextP) { + nextP = currP->_nextP; + delete currP; + } + + _nextP = nullptr; +} + +bool TTconcept::setStatus() { + if (_string1.isValid() && _string2.isValid()) { + _status = SS_VALID; + return true; + } else { + _status = SS_11; + return false; + } +} + +void TTconcept::setScriptType(ScriptType scriptType) { + _nextP = nullptr; + _field14 = 0; + _scriptType = scriptType; + _field1C = -1; + _field20 = 0; + _word2P = nullptr; + _field30 = 0; + _field34 = 0; + _flag = false; + _status = 0; +} + +int TTconcept::initializeWordRef(TTword *word) { + delete _wordP; + _wordP = word; + return 0; +} + +void TTconcept::reset() { + delete _wordP; + _wordP = nullptr; + _scriptP = nullptr; + + int oldStatus = _status; + setScriptType(ST_UNKNOWN_SCRIPT); + _status = oldStatus; +} + +bool TTconcept::compareTo(const char *str) const { + return this != nullptr && _wordP != nullptr && + _wordP->compareTo(str); +} + +bool TTconcept::compareTo(TTword *word) const { + if (_wordP && _wordP->compareTo(word->_text)) + return true; + + if (_scriptP && _scriptP->getId() == 1 && word->comparePronounTo(1)) + return true; + + return false; +} + +void TTconcept::initialize(TTconcept &src) { + _nextP = src._nextP; + _field14 = src._field14; + _scriptType = src._scriptType; + _field1C = src._field1C; + _field20 = src._field20; + + if (src._word2P) { + _word2P = src._word2P->copyWords(); + if (src._word2P->getChainStatus()) + _status = 11; + } else { + _word2P = nullptr; + } + + _field30 = src._field30; + _field34 = src._field34; + + if (src._flag) { + g_vm->_exeResources._owner->setParserConcept(this, &src); + src.setFlag(true); + _flag = true; + } + + _status = src._status; +} + +void TTconcept::copyFrom(TTconcept *src) { + if (this != src) { + if (src->getStatus()) { + _status = SS_5; + } else { + _string1 = src->_string1; + _string2 = src->_string2; + + if (setStatus()) { + _scriptP = src->_scriptP; + if (src->_wordP) { + _status = initializeWordRef(src->_wordP); + initialize(*src); + } else { + _wordP = nullptr; + initialize(*src); + } + } + } + } + + if (_status) + reset(); +} + +int TTconcept::setOwner(TTconcept *src) { + if (this) { + if (src->_wordP) { + TTword *newWord = src->_wordP->copy(); + return setOwner(newWord, 1); + } + } + + return 0; +} + +int TTconcept::setOwner(TTword *src, bool dontDup) { + TTword *word = dontDup ? src : src->copy(); + + if (word) { + if (!_word2P) { + _word2P = word; + } else { + // Add word to end of word list + TTword *tailP = _word2P; + while (tailP->_nextP) + tailP = tailP->_nextP; + + tailP->_nextP = word; + } + } + + return 0; +} + +bool TTconcept::checkWordId1() const { + return (_wordP && (_wordP->_id == 200 || _wordP->_id == 201 || + _wordP->_id == 602 || _wordP->_id == 607)) || + (_scriptP && _scriptP->_id <= 2); +} + +bool TTconcept::checkWordId2() const { + return (_wordP && _wordP->_id == 204) || (_scriptP && _scriptP->getId() == 3); +} + +bool TTconcept::checkWordId3() const { + return isWordClass(WC_ABSTRACT) || isWordClass(WC_ADJECTIVE) || + (isWordClass(WC_ADVERB) && getWordId() != 910); +} + +bool TTconcept::checkWordClass() const { + return !_scriptP && _wordP && (_wordP->_wordClass == WC_THING || _wordP->_wordClass == WC_PRONOUN); +} + +const TTstring TTconcept::getText() { + if (_scriptP) + return _scriptP->getText(); + else if (_wordP) + return _wordP->getText(); + else + return TTstring(); +} + +TTconcept *TTconcept::findByWordId(int id) { + for (TTconcept *conceptP = this; conceptP; conceptP = conceptP->_nextP) { + if (conceptP->_wordP && conceptP->_wordP->_id == id) + return conceptP; + } + + return nullptr; +} + +TTconcept *TTconcept::findByWordClass(WordClass wordClass) { + for (TTconcept *conceptP = this; conceptP; conceptP = conceptP->_nextP) { + if (conceptP->_wordP && conceptP->_wordP->_wordClass == wordClass) + return conceptP; + } + + return nullptr; +} + +TTconcept *TTconcept::findBy20(int val) { + for (TTconcept *conceptP = this; conceptP; conceptP = conceptP->_nextP) { + if (conceptP->_field20 == val) + return conceptP; + } + + return nullptr; +} + +bool TTconcept::isWordId(int id) const { + return this && _wordP && _wordP->_id == id; +} + +int TTconcept::getWordId() const { + return this && _wordP ? _wordP->_id : 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_concept.h b/engines/titanic/true_talk/tt_concept.h new file mode 100644 index 0000000000..88afb6f28b --- /dev/null +++ b/engines/titanic/true_talk/tt_concept.h @@ -0,0 +1,172 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_CONCEPT_H +#define TITANIC_TT_CONCEPT_H + +#include "titanic/true_talk/tt_string.h" +#include "titanic/true_talk/tt_word.h" + +namespace Titanic { + +enum ScriptType { ST_UNKNOWN_SCRIPT = 0, ST_ROOM_SCRIPT = 1, ST_NPC_SCRIPT = 2 }; + +class TTscriptBase; +class TTword; + +class TTconcept { +private: + TTstring _string1; + int _field1C; + TTword *_word2P; + int _field30; + bool _flag; + int _status; +private: + /** + * Sets the status of the concept + */ + bool setStatus(); + + /** + * Sets the script type and resets other fields + */ + void setScriptType(ScriptType scriptType); + + /** + * Sets up the concept for a word reference + */ + int initializeWordRef(TTword *word); + + /** + * Resets the concept + */ + void reset(); + + /** + * Initialize inner data for the concept from a given source concept + */ + void initialize(TTconcept &src); +public: + TTconcept *_nextP; + TTscriptBase *_scriptP; + TTword *_wordP; + int _scriptType; + int _field14; + int _field20; + int _field34; + TTstring _string2; +public: + TTconcept(); + TTconcept(TTscriptBase *script, ScriptType scriptType); + TTconcept(TTword *word, ScriptType scriptType = ST_UNKNOWN_SCRIPT); + TTconcept(TTconcept &src); + ~TTconcept(); + + /** + * Destroys any attached sibling concepts to the given concept + */ + void deleteSiblings(); + + /** + * Copies data from a source concept + */ + void copyFrom(TTconcept *src); + + /** + * Compares the name of the associated word, if any, to the passed string + */ + bool compareTo(const char *str) const; + + /** + * Compares the concept to the specified word + */ + bool compareTo(TTword *word) const; + + /** + * Set an owner for the concept + */ + int setOwner(TTconcept *src); + + /** + * Set an owner for the concept + */ + int setOwner(TTword *src, bool dontDup); + + /** + * Return the status of the concept + */ + int getStatus() const { return _status; } + + /** + * True true if the concept is valid + */ + bool isValid() const { return _status == SS_VALID; } + + /** + * Returns true if the word is of the specified class + */ + bool isWordClass(WordClass wordClass) const { + return _wordP && _wordP->isClass(wordClass); + } + + void setFlag(bool val) { _flag = val; } + void set1C(int val) { _field1C = val; } + int get20() const { return _field20; } + int getState() const { return _field34; } + + bool checkWordId1() const; + bool checkWordId2() const; + bool checkWordId3() const; + bool checkWordClass() const; + + /** + * Return text assocaited with the concept's word or script + */ + const TTstring getText(); + + /** + * Find a word by Id + */ + TTconcept *findByWordId(int id); + + /** + * Find a word by it's class + */ + TTconcept *findByWordClass(WordClass wordClass); + + TTconcept *findBy20(int val); + + /** + * Returns true if the concept has a word with a given Id + */ + bool isWordId(int id) const; + + /** + * If a word is associated, return it's Id + */ + int getWordId() const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_CONCEPT_H */ diff --git a/engines/titanic/true_talk/tt_concept_node.cpp b/engines/titanic/true_talk/tt_concept_node.cpp new file mode 100644 index 0000000000..454ca59971 --- /dev/null +++ b/engines/titanic/true_talk/tt_concept_node.cpp @@ -0,0 +1,165 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_concept_node.h" +#include "titanic/true_talk/script_handler.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTconceptNode::TTconceptNode() : _concept0P(_concepts[0]), _concept1P(_concepts[1]), + _concept2P(_concepts[2]), _concept3P(_concepts[3]), _concept4P(_concepts[4]), + _concept5P(_concepts[5]), _field18(0), _field1C(0), _nextP(nullptr), _status(0) { +} + +TTconceptNode::TTconceptNode(const TTconceptNode &src) : _concept0P(_concepts[0]), _concept1P(_concepts[1]), + _concept2P(_concepts[2]), _concept3P(_concepts[3]), _concept4P(_concepts[4]), + _concept5P(_concepts[5]), _field18(0), _field1C(0), _nextP(nullptr), _status(0) { + if (src._status) { + _status = SS_5; + } else { + for (int idx = 0; idx < 6; ++idx) { + if (src._concepts[idx]) { + _concepts[idx] = new TTconcept(*src._concepts[idx]); + if (!_concepts[idx]->isValid()) + _status = SS_11; + } + } + + _field18 = src._field18; + _field1C = src._field1C; + _nextP = src._nextP; + } +} + +void TTconceptNode::deleteSiblings() { + // Iterate through the linked chain of nodes, deleting each in turn + for (TTconceptNode *curP = _nextP, *nextP = nullptr; nextP; curP = nextP) { + nextP = curP->_nextP; + delete curP; + } + + _nextP = nullptr; +} + +TTconcept **TTconceptNode::setConcept(int conceptIndex, TTconcept *src) { + TTconcept **conceptPP = nullptr; + switch (conceptIndex) { + case 1: + conceptPP = &_concept1P; + break; + case 2: + conceptPP = &_concept2P; + break; + case 3: + conceptPP = &_concept3P; + break; + case 4: + conceptPP = &_concept4P; + break; + case 5: + conceptPP = &_concept5P; + break; + default: + break; + } + + bool isPronoun = false; + StringArray &pronouns = g_vm->_scriptHandler->_parser._pronouns; + for (uint idx = 0; idx < pronouns.size() && !isPronoun; ++idx) { + isPronoun = pronouns[idx] == src->getText(); + } + + CScriptHandler &scrHandler = *g_vm->_exeResources._owner; + if (!isPronoun) { + switch (conceptIndex) { + case 0: + delete scrHandler._concept2P; + scrHandler._concept2P = new TTconcept(*src); + break; + + case 1: + delete scrHandler._concept4P; + scrHandler._concept4P = new TTconcept(*src); + break; + + case 2: + delete scrHandler._concept1P; + scrHandler._concept1P = new TTconcept(*src); + break; + + default: + break; + } + } + + return conceptPP; +} + +int TTconceptNode::replaceConcept(int mode, int conceptIndex, TTconcept *concept) { + TTconcept **conceptPP = setConcept(conceptIndex, concept); + + if (mode == 0 || (mode == 1 && !*conceptPP)) { + if (!concept || !concept->isValid()) + return SS_5; + + if (mode == 0 && *conceptPP) { + delete *conceptPP; + } + + *conceptPP = new TTconcept(*concept); + return (*conceptPP)->isValid() ? SS_VALID : SS_11; + } else { + return SS_1; + } +} + +int TTconceptNode::changeConcept(int mode, TTconcept **conceptPP, int conceptIndex) { + TTconcept **newConceptPP = setConcept(conceptIndex, *conceptPP); + + if (mode == 0 || (mode == 1 && !*newConceptPP)) { + if (!*conceptPP) + return SS_5; + + delete *newConceptPP; + *newConceptPP = new TTconcept(**conceptPP); + return SS_VALID; + } else { + return SS_1; + } +} + +bool TTconceptNode::createConcept(int mode, int conceptIndex, TTword *word) { + TTconcept *newConcept = new TTconcept(word, ST_UNKNOWN_SCRIPT); + TTconcept **conceptPP = setConcept(conceptIndex, newConcept); + + if (mode == 0 || (mode == 1 && !*conceptPP)) { + delete *conceptPP; + *conceptPP = newConcept; + return false; + } else { + delete newConcept; + return true; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_concept_node.h b/engines/titanic/true_talk/tt_concept_node.h new file mode 100644 index 0000000000..9a1c3a9912 --- /dev/null +++ b/engines/titanic/true_talk/tt_concept_node.h @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_CONCEPT_NODE_H +#define TITANIC_TT_CONCEPT_NODE_H + +#include "titanic/true_talk/tt_concept.h" + +namespace Titanic { + +class TTconceptNode { +public: + TTconcept *_concepts[6]; + TTconcept *&_concept0P; + TTconcept *&_concept1P; + TTconcept *&_concept2P; + TTconcept *&_concept3P; + TTconcept *&_concept4P; + TTconcept *&_concept5P; + int _field18; + int _field1C; + TTconceptNode *_nextP; + int _status; +public: + TTconceptNode(); + TTconceptNode(const TTconceptNode &src); + + /** + * Delete any sibling chain attached to this node + */ + void deleteSiblings(); + + void set18(int val) { _field18 = val; } + int get18() const { return _field18; } + + /** + * Returns true if the node is valid + */ + bool isValid() const { return _status == SS_VALID; } + + TTconcept **setConcept(int conceptIndex, TTconcept *src); + int replaceConcept(int mode, int conceptIndex, TTconcept *concept); + int changeConcept(int mode, TTconcept **conceptPP, int conceptIndex); + bool createConcept(int mode, int conceptIndex, TTword *word); + + int concept1WordId() const { + return _concept1P ? _concept1P->getWordId() : 0; + } + int concept5WordId() const { + return _concept5P ? _concept5P->getWordId() : 0; + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_CONCEPT_NODE_H */ diff --git a/engines/titanic/true_talk/tt_hist.cpp b/engines/titanic/true_talk/tt_hist.cpp new file mode 100644 index 0000000000..fae9ae6286 --- /dev/null +++ b/engines/titanic/true_talk/tt_hist.cpp @@ -0,0 +1,36 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_hist.h" +#include "titanic/true_talk/tt_sentence.h" + +namespace Titanic { + +TThist::TThist(TTsentence *sentence) : _status(0) { + _sentence = new TTsentence(sentence); +} + +TThist::~TThist() { + delete _sentence; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_hist.h b/engines/titanic/true_talk/tt_hist.h new file mode 100644 index 0000000000..f67a0387c5 --- /dev/null +++ b/engines/titanic/true_talk/tt_hist.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_HIST_H +#define TITANIC_TT_HIST_H + +namespace Titanic { + +class TTsentence; + +class TThist { +protected: + int _field0; + TTsentence *_sentence; + int _status; +public: + TThist(TTsentence *sentence); + virtual ~TThist(); +}; + +class TTscriptHist : public TThist { +public: + TTscriptHist(TTsentence *sentence) : TThist(sentence) {} +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_HIST_H */ diff --git a/engines/titanic/true_talk/tt_major_word.cpp b/engines/titanic/true_talk/tt_major_word.cpp new file mode 100644 index 0000000000..18a56a40be --- /dev/null +++ b/engines/titanic/true_talk/tt_major_word.cpp @@ -0,0 +1,70 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_major_word.h" + +namespace Titanic { + +bool TTmajorWord::_staticFlag; + +TTmajorWord::TTmajorWord(const TTstring &str, WordClass wordClass, int val2, int val3) : + TTword(str, wordClass, val2), _field2C(val3) { +} + +TTmajorWord::TTmajorWord(const TTmajorWord *src) : TTword(src) { + if (src->getStatus()) { + _field2C = 0; + _status = SS_5; + } else { + _field2C = src->_field2C; + } +} + +int TTmajorWord::saveData(SimpleFile *file, int val) const { + int result = TTword::save(file); + if (!result) { + file->writeFormat("%1.0d", val); + file->writeFormat("%c", '\n'); + if (_synP) + result = _synP->save(file); + } + + return result; +} + +TTword *TTmajorWord::copy() const { + TTmajorWord *returnWordP = new TTmajorWord(this); + returnWordP->_status = _status; + if (!_status) { + _staticFlag = false; + return returnWordP; + } else if (_status == SS_13 && !_staticFlag) { + _staticFlag = true; + delete returnWordP; + return copy(); + } else { + delete returnWordP; + return nullptr; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_major_word.h b/engines/titanic/true_talk/tt_major_word.h new file mode 100644 index 0000000000..c9a708abfb --- /dev/null +++ b/engines/titanic/true_talk/tt_major_word.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_MAJOR_WORD_H +#define TITANIC_TT_MAJOR_WORD_H + +#include "titanic/true_talk/tt_word.h" + +namespace Titanic { + +class TTmajorWord : public TTword { +private: + static bool _staticFlag; +protected: + int _field2C; +protected: + /** + * Dumps data for the word to a file + */ + int saveData(SimpleFile *file, int val) const; +public: + TTmajorWord(const TTstring &str, WordClass wordClass, int val2, int val3); + TTmajorWord(const TTmajorWord *src); + + /** + * Creates a copy of the word + */ + virtual TTword *copy() const; + + virtual bool proc2(int val) const { return _field2C == val; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_MAJOR_WORD_H */ diff --git a/engines/titanic/true_talk/tt_node.cpp b/engines/titanic/true_talk/tt_node.cpp new file mode 100644 index 0000000000..cbbb1dd756 --- /dev/null +++ b/engines/titanic/true_talk/tt_node.cpp @@ -0,0 +1,89 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/tt_node.h" + +namespace Titanic { + +TTnode::TTnode() : _priorP(nullptr), _nextP(nullptr) { +} + +TTnode::~TTnode() { + detach(); +} + +void TTnode::addToTail(TTnode *newNode) { + TTnode *tail = getTail(); + tail->_nextP = newNode; + newNode->_priorP = this; +} + +void TTnode::addToHead(TTnode *newNode) { + TTnode *head = getHead(); + head->_priorP = newNode; + newNode->_nextP = head; +} + +void TTnode::detach() { + if (_priorP) + _priorP->_nextP = _nextP; + + if (_nextP) + _nextP->_priorP = _priorP; +} + +void TTnode::deleteSiblings() { + // Detach current node from prior one, if there is one + if (_priorP) + _priorP->_nextP = nullptr; + + // Iterate through the linked chain of nodes, deleting each in turn + for (TTnode *curP = _nextP, *nextP = nullptr; nextP; curP = nextP) { + nextP = curP->_nextP; + delete curP; + } +} + +TTnode *TTnode::getHead() { + if (_priorP == nullptr) + return this; + + TTnode *node = _priorP; + while (node->_priorP) + node = node->_priorP; + + return node; +} + +TTnode *TTnode::getTail() { + if (_nextP == nullptr) + return this; + + TTnode *node = _nextP; + while (node->_nextP) + node = node->_nextP; + + return node; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_node.h b/engines/titanic/true_talk/tt_node.h new file mode 100644 index 0000000000..36d44288fd --- /dev/null +++ b/engines/titanic/true_talk/tt_node.h @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_NODE_H +#define TITANIC_TT_NODE_H + +namespace Titanic { + +class TTnode { +public: + TTnode *_priorP; + TTnode *_nextP; +public: + TTnode(); + virtual ~TTnode(); + + /** + * Adds a new node at the beginning of the linked list + */ + void addToHead(TTnode *newNode); + + /** + * Links the passed node to this node as a linked list + */ + void addToTail(TTnode *newNode); + + /** + * Detaches a node from any predecessor and/or successor + */ + void detach(); + + /** + * Delete any sibling chain attached to this node + */ + void deleteSiblings(); + + /** + * Returns the first node at the beginning of a linked list of nodes + */ + TTnode *getHead(); + + /** + * Returns the final node at the end of the linked list of nodes + */ + TTnode *getTail(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_NODE_H */ diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp new file mode 100644 index 0000000000..61c3b0e00c --- /dev/null +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -0,0 +1,1009 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/algorithm.h" +#include "common/textconsole.h" +#include "titanic/messages/messages.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/true_talk/tt_npc_script.h" +#include "titanic/true_talk/tt_sentence.h" +#include "titanic/true_talk/true_talk_manager.h" +#include "titanic/game_manager.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTsentenceEntries *TTnpcScript::_defaultEntries; + +static const char *const ITEMS[] = { + "chicken", "napkin", "parrot", "moth", "fuse", "eye", "nose", "ear", "mouth", + "auditorycenter", "visioncenter", "olfactorycenter", "speechcenter", "stick", + "longstick", "bomb", "lemon", "puree", "television", "hammer", nullptr +}; + +struct ItemRec { + const char *const _name; + uint _id; +}; +static const ItemRec ARRAY1[] = { + { ITEMS[0], 290138 }, + { ITEMS[1], 290139 }, + { ITEMS[2], 290141 }, + { ITEMS[3], 290142 }, + { ITEMS[4], 290153 }, + { ITEMS[5], 290158 }, + { ITEMS[6], 290159 }, + { ITEMS[7], 290160 }, + { ITEMS[8], 290161 }, + { ITEMS[9], 290162 }, + { ITEMS[10], 290163 }, + { ITEMS[11], 290164 }, + { ITEMS[12], 290165 }, + { ITEMS[13], 290166 }, + { ITEMS[14], 290166 }, + { ITEMS[15], 290178 }, + { ITEMS[16], 290174 }, + { ITEMS[17], 290175 }, + { ITEMS[18], 290176 }, + { ITEMS[19], 290179 }, + { nullptr, 0 } +}; +static const uint ARRAY2[] = { + 290167, 290178, 290183, 290144, 290148, 290151, 290154, 290156, 290158, 290159, 290160, 290161, + 290162, 290163, 290164, 290165, 290177, 290181, 0 +}; +static const uint RANDOM1[] = { + 290184, 290185, 290187, 290188, 290190, 290191, 290193, 290195, 290196, 290197, 290198, 290199, + 290202, 290205, 0 +}; +static const uint RANDOM2[] = { + 290186, 290187, 290188, 290190, 290191, 290193, 290194, 290195, 290196, 290197, 290198, 290199, + 290200, 290201, 290202, 290204, 290205, 0 +}; +static const uint RANDOM3[] = { + 290188, 290190, 290192, 290194, 290197, 290200, 290201, 290202, 290204, 290205, 0 +}; +static const uint RANDOM4[] = { + 290206, 290207, 290209, 290210, 290211, 290212, 290216, 290217, 290218, 290219, 290222, 290223, 0 +}; +static const uint RANDOM5[] = { + 290208, 290209, 290210, 290211, 290212, 290214, 290215, 290216, 290217, 290218, 290219, 290221, + 290222, 290223, 0 +}; +static const uint RANDOM6[] = { + 290210, 290211, 290213, 290214, 290215, 290220, 290221, 290222, 290223, 0 +}; +static const uint RANDOM7[] = { + 290225, 290226, 290228, 290229, 290230, 290232, 290231, 290235, 290236, 290237, 290238, 290241, 0 +}; +static const uint RANDOM8[] = { + 290227, 290228, 290229, 290230, 290231, 290232, 290233, 290234, 290235, 290236, 290237, 290238, + 290240, 290241, 0 +}; +static const uint RANDOM9[] = { + 290228, 290229, 290230, 290232, 290233, 290234, 290239, 290240, 290241, 0 +}; + +/*------------------------------------------------------------------------*/ + +TTnpcData::TTnpcData() { + Common::fill(&_array[0], &_array[136], 0); +} + +void TTnpcData::resetFlags() { + Common::fill(&_array[20], &_array[136], 0); +} + +/*------------------------------------------------------------------------*/ + +TTnpcScriptBase::TTnpcScriptBase(int charId_, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : + TTscriptBase(0, charClass, v2, charName, v3, v4, v5, v6, v7), + _charId(charId_), _field54(0), _val2(val2) { +} + +/*------------------------------------------------------------------------*/ + +void TTnpcScript::init() { + _defaultEntries = new TTsentenceEntries(); + _defaultEntries->load("Sentences/Default"); +} + +void TTnpcScript::deinit() { + delete _defaultEntries; + _defaultEntries = nullptr; +} + +TTnpcScript::TTnpcScript(int charId_, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, int v5, int v6, int v7) : + TTnpcScriptBase(charId_, charClass, v2, charName, v3, val2, v4, v5, v6, v7), + _entryCount(0), _field68(0), _field6C(0), _rangeResetCtr(0), + _currentDialNum(0), _dialDelta(0), _field7C(0), _itemStringP(nullptr), _field2CC(false) { + CTrueTalkManager::_v2 = 0; + Common::fill(&_dialValues[0], &_dialValues[DIALS_ARRAY_COUNT], 0); + + if (!CTrueTalkManager::_v10) { + Common::fill(&CTrueTalkManager::_v11[0], &CTrueTalkManager::_v11[41], 0); + CTrueTalkManager::_v10 = true; + } + + resetFlags(); +} + +void TTnpcScript::loadResponses(const char *name, int valuesPerResponse) { + _valuesPerResponse = valuesPerResponse; + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + TTnpcScriptResponse sr; + sr._tag = r->readUint32LE(); + for (int idx = 0; idx < valuesPerResponse; ++idx) + sr._values[idx] = r->readUint32LE(); + + _responses.push_back(sr); + } + + delete r; +} + +void TTnpcScript::loadRanges(const char *name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + + while (r->pos() < r->size()) { + Common::Array<uint> values; + uint id = r->readUint32LE(); + bool isRandom = r->readByte(); + bool isSequential = r->readByte(); + + uint v; + do { + v = r->readUint32LE(); + values.push_back(v); + } while (v); + + addRange(id, values, isRandom, isSequential); + } + + delete r; +} + +void TTnpcScript::resetFlags() { + _data.resetFlags(); + _field2CC = false; +} + +void TTnpcScript::setupDials(int dial1, int dial2, int dial3) { + _dialValues[0] = dial1; + _dialValues[1] = dial2; + _dialValues[2] = dial3; + _currentDialNum = getRandomNumber(3) - 1; + _dialDelta = getRandomNumber(5) + 6; + + if (_dialValues[0] > 70) + _dialDelta = -_dialDelta; +} + +void TTnpcScript::addResponse(int id) { + if (id > 200000) + id = getDialogueId(id); + + handleWord(id); + TTscriptBase::addResponse(id); +} + +int TTnpcScript::chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) { + for (uint idx = 0; idx < _responses.size(); ++idx) { + const TTnpcScriptResponse &response = _responses[idx]; + + if (response._tag == tag) { + if (_valuesPerResponse == 1) { + selectResponse(response._values[0]); + } else { + int valIndex = getRandomNumber(response.size()) - 1; + uint diagId = getDialogueId(response._values[valIndex]); + addResponse(diagId); + } + + applyResponse(); + return 2; + } + } + + return 1; +} + +int TTnpcScript::process(const TTroomScript *roomScript, const TTsentence *sentence) { + return processEntries(&_entries, _entryCount, roomScript, sentence); +} + +int TTnpcScript::proc8() const { + return 0; +} + +int TTnpcScript::proc11() const { + return 2; +} + +int TTnpcScript::proc12() const { + return 1; +} + +void TTnpcScript::selectResponse(int id) { + if (id >= 200000 && id <= 290264) + id = getDialogueId(id); + + addResponse(id); +} + +bool TTnpcScript::handleWord(uint id) const { + if (_words.empty()) + return false; + + for (uint idx = 0; idx < _words.size(); ++idx) { + const TTwordEntry &we = _words[idx]; + if (we._id == id) { + TTstring str(we._text); + g_vm->_scriptHandler->handleWord(&str); + return true; + } + } + + g_vm->_scriptHandler->handleWord(nullptr); + return true; +} + +int TTnpcScript::handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder) { + if (_quotes.empty()) + return 1; + + + int loopCounter = 0; + for (uint idx = 0; idx < _quotes.size() && loopCounter < 2; ++idx) { + const TThandleQuoteEntry *qe = &_quotes[idx]; + + if (!qe->_index) { + // End of list; start at beginning again + ++loopCounter; + idx = 0; + qe = &_quotes[0]; + } + + if (qe->_index == val && ( + (tagId == 0 && loopCounter == 2) || + (qe->_tagId < MKTAG('A', 'A', 'A', 'A')) || + (qe->_tagId == tagId) + )) { + uint foundTagId = qe->_tagId; + if (foundTagId > 0 && foundTagId < 100) { + if (!tagId) + foundTagId >>= 1; + if (getRandomNumber(100) < foundTagId) + return 1; + } + + uint dialogueId = qe->_dialogueId; + if (dialogueId >= _quotes._rangeStart && dialogueId <= _quotes._rangeEnd) { + dialogueId -= _quotes._rangeStart; + if (dialogueId > 3) + error("Invalid dialogue index in BarbotScript"); + + const int RANDOM_LIMITS[4] = { 30, 50, 70, 60 }; + int rangeLimit = RANDOM_LIMITS[dialogueId]; + int dialRegion = getDialRegion(0); + + if (dialRegion != 1) { + rangeLimit = MAX(rangeLimit - 20, 20); + } + + dialogueId = (((int)remainder + 25) % 100) >= rangeLimit + ? _quotes._tag1 : _quotes._tag2; + } + + addResponse(getDialogueId(dialogueId)); + applyResponse(); + return 2; + } + } + + return 1; + +} + +uint TTnpcScript::getRangeValue(uint id) { + TTscriptRange *range = findRange(id); + if (!range) + return 0; + + switch (range->_mode) { + case SF_RANDOM: { + uint count = range->_values.size(); + + uint index = getRandomNumber(count) - 1; + if (count > 1 && range->_values[index] == range->_priorIndex) { + for (int retry = 0; retry < 8 && index != range->_priorIndex; ++retry) + index = getRandomNumber(count) - 1; + } + + range->_priorIndex = index; + return range->_values[index]; + } + + case SF_SEQUENTIAL: { + // Get the next value from the array sequentially + int val = range->_values[range->_priorIndex]; + if (!val) { + // Reached end of array, so reset back to start + range->_priorIndex = 1; + val = range->_values[1]; + } + + ++range->_priorIndex; + return val; + } + + default: + if (range->_values[range->_priorIndex]) + return range->_values[range->_priorIndex++]; + + range->_priorIndex = 1; + ++_rangeResetCtr; + return range->_values[0]; + } +} + +void TTnpcScript::resetRange(int id) { + TTscriptRange *range = findRange(id); + if (range && range->_mode != SF_RANDOM) + range->_priorIndex = 0; +} + +int TTnpcScript::updateState(uint oldId, uint newId, int index) { + return newId; +} + +int TTnpcScript::preResponse(uint id) { + return 0; +} + +const TTscriptMapping *TTnpcScript::getMapping(int index) { + if (index >= 0 && index < (int)_mappings.size()) + return &_mappings[index]; + return nullptr; +} + +int TTnpcScript::doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence) { + return 0; +} + +void TTnpcScript::save(SimpleFile *file) { + file->writeNumber(charId()); + saveBody(file); + + file->writeNumber(4); + file->writeNumber(_rangeResetCtr); + file->writeNumber(_currentDialNum); + file->writeNumber(_dialDelta); + file->writeNumber(_field7C); + + file->writeNumber(10); + for (int idx = 0; idx < 10; ++idx) + file->writeNumber(_data[idx]); +} + +void TTnpcScript::load(SimpleFile *file) { + loadBody(file); + + int count = file->readNumber(); + _rangeResetCtr = file->readNumber(); + _currentDialNum = file->readNumber(); + _dialDelta = file->readNumber(); + _field7C = file->readNumber(); + + for (int idx = count; idx > 4; --idx) + file->readNumber(); + + count = file->readNumber(); + for (int idx = 0; idx < count; ++idx) { + int v = file->readNumber(); + if (idx < 10) + _data[idx] = v; + } +} + +void TTnpcScript::saveBody(SimpleFile *file) { + int count = proc31(); + file->writeNumber(count); + + if (count > 0) { + for (uint idx = 0; idx < _ranges.size(); ++idx) { + const TTscriptRange &item = _ranges[idx]; + if (item._mode == SF_RANDOM && item._priorIndex) { + file->writeNumber(item._id); + file->writeNumber(item._priorIndex); + } + } + } +} + +void TTnpcScript::loadBody(SimpleFile *file) { + int count = file->readNumber(); + preLoad(); + + for (int index = 0; index < count; index += 2) { + int id = file->readNumber(); + int val = file->readNumber(); + + for (uint idx = 0; idx < _ranges.size(); ++idx) { + TTscriptRange &item = _ranges[idx]; + if (item._id == (uint)id) { + item._priorIndex = val; + break; + } + } + } +} + +int TTnpcScript::proc31() const { + int count = 0; + for (uint idx = 0; idx < _ranges.size(); ++idx) { + const TTscriptRange &item = _ranges[idx]; + if (item._mode != SF_RANDOM && item._priorIndex) + ++count; + } + + return count * 2; +} + +void TTnpcScript::setDialRegion(int dialNum, int region) { + if (dialNum < DIALS_ARRAY_COUNT) + _dialValues[dialNum] = region * 100; + + if (g_vm->_trueTalkManager) { + CPetControl *petControl = getPetControl(g_vm->_trueTalkManager->getGameManager()); + if (petControl) + petControl->playSound(1); + } +} + +void TTnpcScript::setDial(int dialNum, int value) { + if (dialNum < DIALS_ARRAY_COUNT) { + int oldRegion = getDialRegion(dialNum); + + int newRegion = 1; + if (value < 50) + newRegion = 0; + else if (value > 150) + newRegion = 2; + + if (oldRegion == newRegion) + setDialRegion(dialNum, newRegion); + + _dialValues[dialNum] = value; + } + + if (g_vm->_trueTalkManager) { + CPetControl *petControl = getPetControl(g_vm->_trueTalkManager->getGameManager()); + if (petControl) + petControl->convResetDials(); + } +} + +int TTnpcScript::getDialRegion(int dialNum) const { + if (dialNum < DIALS_ARRAY_COUNT) { + int value = _dialValues[dialNum]; + if (value < 50) + return 0; + else if (value > 150) + return 2; + else + return 1; + } else { + return 0; + } +} + +int TTnpcScript::getDialLevel(uint dialNum, bool randomizeFlag) { + int result = _dialValues[dialNum]; + if (randomizeFlag) { + bool lowFlag = result <= 50; + result = CLIP(result + (int)getRandomNumber(18) - 9, 0, 100); + + if (lowFlag) { + result = MIN(result, 46); + } else { + result = MAX(result, 54); + } + } + + return result; +} + +bool TTnpcScript::randomResponse(uint index) { + return false; +} + +uint TTnpcScript::translateId(uint id) const { + for (uint idx = 0; idx < _tagMappings.size(); ++idx) { + if (_tagMappings[idx]._src == id) + return _tagMappings[idx]._dest; + } + + return 0; +} + +void TTnpcScript::preLoad() { + for (uint idx = 0; idx < _ranges.size(); ++idx) + _ranges[idx]._priorIndex = 0; +} + +int TTnpcScript::getRoom54(int roomId) { + TTroomScript *room = g_vm->_trueTalkManager->getRoomScript(roomId); + return room ? room->_field54 : 0; +} + +int TTnpcScript::getValue(int testNum) const { + switch (testNum) { + case 0: + return CTrueTalkManager::_v2; + + case 1: + if (g_vm->_trueTalkManager) + CTrueTalkManager::_v3 = g_vm->_trueTalkManager->getPassengerClass(); + return CTrueTalkManager::_v3; + + case 2: + return CTrueTalkManager::_v4; + + case 3: + return CTrueTalkManager::_v5 != 0; + + case 4: + if (g_vm->_trueTalkManager) { + switch (g_vm->_trueTalkManager->getState14()) { + case 1: + CTrueTalkManager::_v6 = 3; + break; + case 2: + CTrueTalkManager::_v6 = 0; + break; + case 3: + CTrueTalkManager::_v6 = 1; + break; + default: + CTrueTalkManager::_v6 = 2; + break; + } + } + return CTrueTalkManager::_v6; + + case 5: + return CTrueTalkManager::_v7; + + case 6: + return CTrueTalkManager::_v8 != 0; + + case 7: + return !!getRoom54(123); + + default: + return CTrueTalkManager::_v11[testNum]; + } +} + +uint TTnpcScript::getRandomNumber(int max) const { + return 1 + g_vm->getRandomNumber(max - 1); +} + +uint TTnpcScript::getDialogueId(uint tagId) { + if (tagId < 200000) + return tagId; + + // Perform any script specific translation + uint origId = tagId; + if (tagId >= 290000 && tagId <= 290263) + tagId = translateId(tagId); + if (!tagId) + return 0; + + if (!_field2CC) { + _field2CC = true; + int val = translateByArray(tagId); + if (val > 0) { + if (randomResponse(val)) + return 4; + } + } + + uint oldTagId = tagId; + tagId = getRangeValue(tagId); + if (tagId != oldTagId) + tagId = getRangeValue(tagId); + + oldTagId = getDialsBitset(); + uint newId = updateState(origId, tagId, oldTagId); + if (!newId) + return 0; + + int idx = 0; + const TTscriptMapping *tableP; + for (;;) { + tableP = getMapping(idx++); + if (!tableP) + return 0; + + if (tableP->_id == newId) + break; + } + uint newVal = tableP->_values[oldTagId]; + + // First slot dialogue Ids + idx = 0; + int *arrP = _data.getSlot(0); + while (idx < 4 && arrP[idx]) + ++idx; + + if (idx == 4) + return newVal; + arrP[idx] = origId; + + // Second slot dialogue Ids + idx = 0; + arrP = _data.getSlot(1); + while (idx < 4 && arrP[idx]) + ++idx; + + if (idx == 4) + return newVal; + arrP[idx] = newVal; + + return newVal; +} + +int TTnpcScript::translateByArray(int id) { + for (uint idx = 1, arrIndex = 35; idx < 15; ++idx, arrIndex += 8) { + if (_data[idx - 1] == id && _data[idx] == 0) + return idx; + } + + return -1; +} + +CPetControl *TTnpcScript::getPetControl(CGameManager *gameManager) { + if (gameManager && gameManager->_project) + return gameManager->_project->getPetControl(); + return nullptr; +} + +int TTnpcScript::processEntries(const TTsentenceEntries *entries, uint entryCount, const TTroomScript *roomScript, const TTsentence *sentence) { + if (!entries) + return SS_1; + if (!entryCount) + // No count specified, so use entire list + entryCount = entries->size(); + int entryId = _field2C; + + for (uint loopCtr = 0; loopCtr < 2; ++loopCtr) { + for (uint entryCtr = 0; entryCtr < entryCount; ++entryCtr) { + const TTsentenceEntry &entry = (*entries)[entryCtr]; + if (entry._field4 != entryId && (loopCtr == 0 || entry._field4)) + continue; + + bool flag; + if (entry._fieldC || entry._string10.empty()) { + flag = sentence->fn1(entry._string8, entry._fieldC, + entry._string14, entry._string18, entry._string1C, + entry._field20, entry._field28, 0, nullptr); + } else { + flag = sentence->fn3(entry._string8, entry._string10, + entry._string14, entry._string18, entry._string1C, + entry._string24, entry._field28, 0, nullptr); + } + + if (flag) { + if (entry._field2C) { + bool flag2 = true; + if (entry._field2C & 0x1000000) + flag2 = sentence->isConcept34(1); + + if (entry._field2C & 0x2000000) + flag2 = sentence->isConcept34(0) || sentence->isConcept34(4); + + if (!flag2) { + flag = false; + } else { + int result = doSentenceEntry(entry._field2C & 0xFFFFFF, &entry._field0, + roomScript, sentence); + if (result == 2) + return 2; + flag = !result; + } + } + + if (flag) { + int dialogueId = getDialogueId(entry._field0); + int id; + if (!dialogueId) + return 1; + else if (dialogueId == 4) + return 2; + addResponse(dialogueId); + + id = preResponse(dialogueId); + if (id) + addResponse(getDialogueId(id)); + applyResponse(); + + if (entry._field30) + postResponse(entry._field30, &entry, roomScript, sentence); + + return 2; + } + } + } + } + + return 1; +} + +bool TTnpcScript::defaultProcess(const TTroomScript *roomScript, const TTsentence *sentence) { + uint remainder; + TTtreeResult results[32]; + const TTstring &line = sentence->_normalizedLine; + + uint tagId = g_vm->_trueTalkManager->_quotes.find(line.c_str()); + int val = g_vm->_trueTalkManager->_quotesTree.search(line.c_str(), TREE_1, results, tagId, &remainder); + + if (val > 0) { + if (!handleQuote(roomScript, sentence, val, tagId, remainder)) + return true; + } + + if (tagId) { + if (chooseResponse(roomScript, sentence, tagId) == 2) + return true; + } + + return false; +} + +void TTnpcScript::addRange(uint id, const Common::Array<uint> &values, bool isRandom, bool isSequential) { + _ranges.push_back(TTscriptRange(id, values, isRandom, isSequential)); +} + +TTscriptRange *TTnpcScript::findRange(uint id) { + for (uint idx = 0; idx < _ranges.size(); ++idx) { + if (_ranges[idx]._id == id) + return &_ranges[idx]; + } + + return nullptr; +} + +void TTnpcScript::checkItems(const TTroomScript *roomScript, const TTsentence *sentence) { + _field2CC = 0; + ++CTrueTalkManager::_v2; + + if (sentence) { + if (!_itemStringP || getRandomNumber(100) > 80) { + for (const char *const *strP = &ITEMS[0]; *strP; ++strP) { + if (sentence->localWord(*strP)) { + _itemStringP = *strP; + break; + } + } + } + + if (sentence->localWord("bomb")) + _field7C = 1; + } +} + +bool TTnpcScript::addRandomResponse(bool flag) { + if (getValue(1) > 3) + return false; + + const uint *data; + if (flag) { + if (getValue(1) == 2) + data = RANDOM8; + else if (getValue(1) == 1) + data = RANDOM7; + else + data = RANDOM9; + } else if (getRandomBit()) { + if (getValue(1) == 2) + data = RANDOM2; + else if (getValue(1) == 1) + data = RANDOM1; + else + data = RANDOM3; + } else { + if (getValue(1) == 2) + data = RANDOM5; + else if (getValue(1) == 1) + data = RANDOM4; + else + data = RANDOM6; + } + + // Pick a random entry + uint count = 0; + while (data[count]) + ++count; + uint id = data[getRandomNumber(count - 1)]; + + if (id == 290188 && getRoom54(101)) + id = 290189; + else if (id == 290202 && getRoom54(123)) + id = 290203; + + if (!id) + return false; + id = getDialogueId(id); + if (id == 4) + return true; + if (!id) + return false; + + if (flag) + addResponse(getDialogueId(290224)); + + addResponse(id); + applyResponse(); + return true; +} + +void TTnpcScript::updateCurrentDial(bool changeDial) { + int dialLevel = CLIP(getDialLevel(_currentDialNum) + _dialDelta, 0, 100); + setDial(_currentDialNum, dialLevel); + + bool edgeFlag = false; + if (_dialDelta < 0) { + if (dialLevel < 10 || getRandomNumber(100) > 93) + edgeFlag = true; + } else { + if (dialLevel > 90 || getRandomNumber(100) > 93) + edgeFlag = true; + } + + if (edgeFlag) { + if (changeDial) + _currentDialNum = getRandomNumber(3); + + _dialDelta = getRandomNumber(12) + 3; + dialLevel = getDialLevel(_currentDialNum, false); + if (dialLevel > 50) + _dialDelta = -_dialDelta; + } +} + +bool TTnpcScript::fn10(bool flag) { + if (_itemStringP) { + for (const ItemRec *ir = ARRAY1; ir->_id; ++ir) { + if (!strcmp(ir->_name, _itemStringP)) { + _itemStringP = nullptr; + uint id = getDialogueId(ir->_id); + if (id == 4) { + return true; + } else if (id != 0) { + addResponse(id); + applyResponse(); + return true; + } + break; + } + } + + _itemStringP = nullptr; + } + + if (flag && getRandomNumber(100) > 60) { + int val = getRandomNumber(18) - 1; + + if (val == 0 && !getRoom54(101) && !getRoom54(132)) + val = -1; + else if ((val == 1 && !_field7C) || val == 2) + val = -1; + + if (val >= 0) { + val = getDialogueId(ARRAY2[val]); + if (val == 4) { + return true; + } else { + addResponse(val); + applyResponse(); + return true; + } + } + } + + return false; +} + +bool TTnpcScript::getStateValue() const { + if (!CTrueTalkManager::_currentNPC) + return false; + + CGameObject *bomb; + if (CTrueTalkManager::_currentNPC->find("Bomb", &bomb, FIND_GLOBAL) && bomb) { + CTrueTalkGetStateValueMsg stateMsg(10, -1000); + stateMsg.execute(bomb); + if (stateMsg._stateVal) + return true; + } + + return false; +} + +bool TTnpcScript::sentence2C(const TTsentence *sentence) { + return sentence->_field2C >= 2 && sentence->_field2C <= 7; +} + +void TTnpcScript::getAssignedRoom(int *roomNum, int *floorNum, int *elevatorNum) const { + if (roomNum) + *roomNum = 5; + if (floorNum) + *floorNum = 40; + if (elevatorNum) + *elevatorNum = 3; + + CGameManager *gameManager = g_vm->_trueTalkManager->getGameManager(); + CPetControl *petControl = getPetControl(gameManager); + if (petControl) { + if (roomNum) + *roomNum = petControl->getAssignedRoomNum(); + if (floorNum) + *floorNum = petControl->getAssignedFloorNum(); + if (elevatorNum) + *elevatorNum = petControl->getAssignedElevatorNum(); + } + + if (floorNum) + *floorNum = CLIP(*floorNum, 1, 42); + if (roomNum) + *roomNum = CLIP(*roomNum, 1, 18); + if (elevatorNum) + *elevatorNum = CLIP(*elevatorNum, 1, 4); +} + +void TTnpcScript::setResponseFromArray(int index, int id) { + if (index >= 0 && index <= 15) { + deleteResponses(); + if (id) + addResponse(getDialogueId(id)); + + // Add any loaded responses + int *vals = _data.getSlot(index + 1); + for (int idx = 0; idx < 4; ++idx) { + if (vals[idx]) + addResponse(vals[idx]); + } + applyResponse(); + + // Clear out the values used + if (index) + Common::fill(vals, vals + 4, 0); + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h new file mode 100644 index 0000000000..b9afdfad8a --- /dev/null +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -0,0 +1,355 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_NPC_SCRIPT_H +#define TITANIC_TT_NPC_SCRIPT_H + +#include "titanic/support/simple_file.h" +#include "titanic/true_talk/tt_script_base.h" +#include "titanic/true_talk/script_support.h" + +namespace Titanic { + +#define DIALS_ARRAY_COUNT 10 + +class CGameManager; +class CPetControl; +class TTroomScript; + +struct TTnpcData { +private: + int _array[136]; +public: + TTnpcData(); + int &operator[](int idx) { return _array[idx]; } + int *getSlot(int idx) { return &_array[16 + idx * 4]; } + void resetFlags(); +}; + +class TTnpcScriptBase : public TTscriptBase { +protected: + int _field54; + int _val2; +public: + int _charId; +public: + TTnpcScriptBase(int charId, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, + int v5, int v6, int v7); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag) = 0; + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence) = 0; + + virtual int proc8() const = 0; + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(uint id) = 0; + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id) = 0; + + virtual int proc11() const = 0; + virtual int proc12() const = 0; + + int charId() const { return _charId; } +}; + +class TTnpcScript : public TTnpcScriptBase { +private: + int translateByArray(int id); +protected: + static TTsentenceEntries *_defaultEntries; +protected: + Common::Array<TTnpcScriptResponse> _responses; + int _valuesPerResponse; + Common::Array<TTscriptRange> _ranges; + TTscriptMappings _mappings; + TTsentenceEntries _entries; + TTtagMappings _tagMappings; + TTwordEntries _words; + TThandleQuoteEntries _quotes; + int _entryCount; + int _field68; + int _field6C; + int _rangeResetCtr; + int _currentDialNum; + int _dialDelta; + int _field7C; + const char *_itemStringP; + int _dialValues[DIALS_ARRAY_COUNT]; + TTnpcData _data; + bool _field2CC; +protected: + /** + * Loads response data for the NPC from the given resource + */ + void loadResponses(const char *name, int valuesPerResponse = 1); + + /** + * Load ranges data for the NPC from the given resource + */ + void loadRanges(const char *name); + + /** + * Reset script flags + */ + void resetFlags(); + + /** + * Setup dials + */ + void setupDials(int dial1, int dial2, int dial3); + + static int getRoom54(int roomId); + + /** + * Perform test on various state values + */ + int getValue(int testNum) const; + + /** + * Gets a random number between 1 and a given max + */ + uint getRandomNumber(int max) const; + + /** + * Gets a random number of 0 or 1 + */ + uint getRandomBit() const { + return getRandomNumber(2) - 1; + } + + /** + * Returns a dialogue Id by script tag value Id + */ + uint getDialogueId(uint tagId); + + /** + * Returns a pointer to the PET control + */ + static CPetControl *getPetControl(CGameManager *gameManager); + + /** + * Adds a new item to the list of number ranges + */ + void addRange(uint id, const Common::Array<uint> &values, bool isRandom, bool isSequential); + + /** + * Finds an entry in the list of prevoiusly registered number ranges + */ + TTscriptRange *findRange(uint id); + + /** + * Scans through a list of sentence entries for a matching standardized response + */ + int processEntries(const TTsentenceEntries *entries, uint entryCount, const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Scans through a list of sentence entries for a matching standardized response + */ + int processEntries(const TTroomScript *roomScript, const TTsentence *sentence) { + return processEntries(&_entries, _entryCount, roomScript, sentence); + } + + bool defaultProcess(const TTroomScript *roomScript, const TTsentence *sentence); + + void checkItems(const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Adds a random conversation response + */ + bool addRandomResponse(bool flag); + + /** + * Updates the current dial with the given delta + */ + void updateCurrentDial(bool changeDial); + + bool fn10(bool flag); + + static bool sentence2C(const TTsentence *sentence); + + /** + * Gets the True Talk state value + */ + bool getStateValue() const; + + /** + * Gets the assigned room's room, floor, and elevator number + */ + void getAssignedRoom(int *roomNum, int *floorNum, int *elevatorNum) const; + + /** + * Uses a porition of the state _array to set up a new response + */ + void setResponseFromArray(int index, int id); +public: + static void init(); + static void deinit(); +public: + TTnpcScript(int charId, const char *charClass, int v2, + const char *charName, int v3, int val2, int v4, + int v5, int v6, int v7); + + virtual void addResponse(int id); + + /** + * Chooses and adds a conversation response based on a specified tag Id. + * This default implementation does a lookup into a list of known tags, + * and chooses a random dialogue Id from the available ones for that tag + */ + virtual int chooseResponse(const TTroomScript *roomScript, const TTsentence *sentence, uint tag); + + /** + * Does NPC specific processing of the parsed sentence + */ + virtual int process(const TTroomScript *roomScript, const TTsentence *sentence); + + virtual int proc8() const; + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(uint id) { + return SCR_2; + } + + /** + * Called when the script/id changes + */ + virtual ScriptChangedResult scriptChanged(const TTroomScript *roomScript, uint id) { + return SCR_2; + } + + virtual int proc11() const; + virtual int proc12() const; + + /** + * Translate a passed Id to a dialogue Id if necessary, + * and adds it to the response + */ + virtual void selectResponse(int id); + + /** + * Handles scanning the word list for a given Id, and if + * found adds it to the sentence concept list + */ + virtual bool handleWord(uint id) const; + + virtual int handleQuote(const TTroomScript *roomScript, const TTsentence *sentence, + uint val, uint tagId, uint remainder); + + /** + * Given an Id for a previously registered set of random number values, + * picks one of the array values and returns it.. depending on flags, + * either a random value, or each value in turn + */ + virtual uint getRangeValue(uint id); + + /** + * Resets the prior used index for the specified range + */ + virtual void resetRange(int id); + + /** + * Handles updating NPC state based on specified dialogue Ids and dial positions + */ + virtual int updateState(uint oldId, uint newId, int index); + + /** + * Handles getting a pre-response + */ + virtual int preResponse(uint id); + + /** + * Returns a bitset of the dials being off or not + */ + virtual uint getDialsBitset() const { return 0; } + + virtual const TTscriptMapping *getMapping(int index); + virtual int doSentenceEntry(int val1, const int *srcIdP, const TTroomScript *roomScript, const TTsentence *sentence); + + /** + * Handles any post-response NPC processing + */ + virtual void postResponse(int v1, const TTsentenceEntry *entry, const TTroomScript *roomScript, const TTsentence *sentence) {} + + virtual void save(SimpleFile *file); + virtual void load(SimpleFile *file); + virtual void saveBody(SimpleFile *file); + virtual void loadBody(SimpleFile *file); + virtual int proc31() const; + + /** + * Sets a given dial to be pointing in a specified region (0 to 2) + */ + virtual void setDialRegion(int dialNum, int region); + + /** + * Sets the value for an NPC's dial + */ + virtual void setDial(int dialNum, int value); + + /** + * Returns a dial's region number + */ + virtual int getDialRegion(int dialNum) const; + + /** + * Gets the value for a dial + * @param dialNum Dial number + * @param randomizeFlag If set, introduces a slight random variance so that + * the displayed dial will oscillate randomly around it's real level + */ + virtual int getDialLevel(uint dialNum, bool randomizeFlag = true); + + /** + * Handles a randomzied response + */ + virtual bool randomResponse(uint index); + + virtual uint translateId(uint id) const; + + void preLoad(); + + /** + * Called with the script and id changes + */ + ScriptChangedResult notifyScript(TTroomScript *roomScript, int id) { + return scriptChanged(roomScript, id); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_NPC_SCRIPT_H */ diff --git a/engines/titanic/true_talk/tt_parser.cpp b/engines/titanic/true_talk/tt_parser.cpp new file mode 100644 index 0000000000..1d9c199054 --- /dev/null +++ b/engines/titanic/true_talk/tt_parser.cpp @@ -0,0 +1,1713 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_parser.h" +#include "titanic/true_talk/script_handler.h" +#include "titanic/true_talk/tt_action.h" +#include "titanic/true_talk/tt_concept.h" +#include "titanic/true_talk/tt_picture.h" +#include "titanic/true_talk/tt_sentence.h" +#include "titanic/true_talk/tt_word.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTparser::TTparser(CScriptHandler *owner) : _owner(owner), _sentenceConcept(nullptr), + _sentence(nullptr), _fieldC(0), _field10(0), _field14(0), + _currentWordP(nullptr), _nodesP(nullptr), _conceptP(nullptr) { + loadArrays(); +} + +TTparser::~TTparser() { + if (_nodesP) { + _nodesP->deleteSiblings(); + delete _nodesP; + } + + if (_conceptP) { + _conceptP->deleteSiblings(); + delete _conceptP; + } + + delete _currentWordP; +} + +void TTparser::loadArray(StringArray &arr, const CString &name) { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource(name); + while (r->pos() < r->size()) + arr.push_back(readStringFromStream(r)); + delete r; +} + +void TTparser::loadArrays() { + loadArray(_replacements1, "TEXT/REPLACEMENTS1"); + loadArray(_replacements2, "TEXT/REPLACEMENTS2"); + loadArray(_replacements3, "TEXT/REPLACEMENTS3"); + loadArray(_phrases, "TEXT/PHRASES"); + loadArray(_pronouns, "TEXT/PRONOUNS"); + + Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/NUMBERS"); + while (r->pos() < r->size()) { + NumberEntry ne; + ne._text = readStringFromStream(r); + ne._value = r->readSint32LE(); + ne._flags = r->readUint32LE(); + _numbers.push_back(ne); + } + delete r; +} + +int TTparser::preprocess(TTsentence *sentence) { + _sentence = sentence; + if (normalize(sentence)) + return 0; + + // Scan for and replace common slang and contractions with verbose versions + searchAndReplace(sentence->_normalizedLine, _replacements1); + searchAndReplace(sentence->_normalizedLine, _replacements2); + + // Check entire normalized line against common phrases to replace + for (uint idx = 0; idx < _phrases.size(); idx += 2) { + if (!_phrases[idx].compareTo(sentence->_normalizedLine)) + sentence->_normalizedLine = _phrases[idx + 1]; + } + + // Do a further search and replace of roman numerals to decimal + searchAndReplace(sentence->_normalizedLine, _replacements3); + + // Replace any roman numerals, spelled out words, etc. with decimal numbers + CTrueTalkManager::_v1 = -1000; + int idx = 0; + do { + idx = replaceNumbers(sentence->_normalizedLine, idx); + } while (idx >= 0); + + if (CTrueTalkManager::_v1 == -1000 && !sentence->_normalizedLine.empty()) { + // Scan the text for any numeric digits + for (const char *strP = sentence->_normalizedLine.c_str(); *strP; ++strP) { + if (Common::isDigit(*strP)) { + // Found digit, so convert it and any following ones + CTrueTalkManager::_v1 = atoi(strP); + break; + } + } + } + + return 0; +} + +int TTparser::normalize(TTsentence *sentence) { + TTstring *destLine = new TTstring(); + const TTstring &srcLine = sentence->_initialLine; + int srcSize = srcLine.size(); + int savedIndex = 0; + int counter1 = 0; + int commandVal; + + for (int index = 0; index < srcSize; ++index) { + char c = srcLine[index]; + if (Common::isLower(c)) { + (*destLine) += c; + } else if (Common::isSpace(c)) { + if (!destLine->empty() && destLine->lastChar() != ' ') + (*destLine) += ' '; + } else if (Common::isUpper(c)) { + (*destLine) += toupper(c); + } else if (Common::isDigit(c)) { + if (c == '0' && isEmoticon(srcLine, index)) { + sentence->set38(10); + } else { + // Iterate through all the digits of the number + (*destLine) += c; + while (Common::isDigit(srcLine[index + 1])) + (*destLine) += srcLine[++index]; + } + } else if (Common::isPunct(c)) { + bool flag = false; + switch (c) { + case '!': + sentence->set38(3); + break; + + case '\'': + if (!normalizeContraction(srcLine, index, *destLine)) + flag = true; + break; + + case '.': + sentence->set38(1); + break; + + case ':': + commandVal = isEmoticon(srcLine, index); + if (commandVal) { + sentence->set38(commandVal); + index += 2; + } else { + flag = true; + } + break; + + case ';': + commandVal = isEmoticon(srcLine, index); + if (commandVal == 6) { + sentence->set38(7); + index += 2; + } else if (commandVal != 0) { + sentence->set38(commandVal); + index += 2; + } + break; + + case '<': + ++index; + commandVal = isEmoticon(srcLine, index); + if (commandVal == 6) { + sentence->set38(12); + } else { + --index; + flag = true; + } + break; + + case '>': + ++index; + commandVal = isEmoticon(srcLine, index); + if (commandVal == 6 || commandVal == 9) { + sentence->set38(11); + } else { + --index; + flag = true; + } + break; + + case '?': + sentence->set38(2); + break; + + default: + flag = true; + break; + } + + if (flag && (!savedIndex || (index - savedIndex) == 1)) + ++counter1; + + savedIndex = index; + } + } + + if (counter1 >= 4) + sentence->set38(4); + + // Remove any trailing spaces + while (destLine->hasSuffix(" ")) + destLine->deleteLastChar(); + + // Copy out the normalized line + sentence->_normalizedLine = *destLine; + delete destLine; + + return 0; +} + +int TTparser::isEmoticon(const TTstring &str, int &index) { + if (str[index] != ':' && str[index] != ';') + return 0; + + if (str[index + 1] != '-') + return 0; + + index += 2; + switch (str[index]) { + case '(': + case '<': + return 8; + + case ')': + case '>': + return 6; + + case 'P': + case 'p': + return 9; + + default: + return 5; + } +} + +bool TTparser::normalizeContraction(const TTstring &srcLine, int srcIndex, TTstring &destLine) { + int startIndex = srcIndex + 1; + switch (srcLine[startIndex]) { + case 'd': + srcIndex += 2; + if (srcLine.compareAt(srcIndex, " a ") || srcLine.compareAt(srcIndex, " the ")) { + destLine += " had"; + } else { + destLine += " would"; + } + + srcIndex = startIndex; + break; + + case 'l': + if (srcLine[srcIndex + 2] == 'l') { + // 'll ending + destLine += " will"; + srcIndex = startIndex; + } + break; + + case 'm': + // 'm ending + destLine += " am"; + srcIndex = startIndex; + break; + + case 'r': + // 're ending + if (srcLine[srcIndex + 2] == 'e') { + destLine += " are"; + srcIndex = startIndex; + } + break; + + case 's': + destLine += "s*"; + srcIndex = startIndex; + break; + + case 't': + if (srcLine[srcIndex - 1] == 'n' && srcIndex >= 3) { + if (srcLine[srcIndex - 3] == 'c' && srcLine[srcIndex - 2] == 'a' && + (srcIndex == 3 || srcLine[srcIndex - 4])) { + // can't -> can not + destLine += 'n'; + } else if (srcLine[srcIndex - 3] == 'w' && srcLine[srcIndex - 2] == 'o' && + (srcIndex == 3 || srcLine[srcIndex - 4])) { + // won't -> will not + destLine.deleteLastChar(); + destLine.deleteLastChar(); + destLine += "ill"; + } else if (srcLine[srcIndex - 3] == 'a' && srcLine[srcIndex - 2] == 'i' && + (srcIndex == 3 || srcLine[srcIndex - 4])) { + // ain't -> am not + destLine.deleteLastChar(); + destLine.deleteLastChar(); + destLine += "m"; + } else if (srcLine.hasSuffix(" sha") || + (srcIndex == 4 && srcLine.hasSuffix("sha"))) { + // shan't -> shall not + destLine.deleteLastChar(); + destLine += "ll"; + } + + destLine += " not"; + } + break; + + case 'v': + // 've ending + if (srcLine[startIndex + 2] == 'e') { + destLine += " have"; + srcIndex = startIndex; + } + break; + + default: + break; + } + + return false; +} + +void TTparser::searchAndReplace(TTstring &line, const StringArray &strings) { + int charIndex = 0; + while (charIndex >= 0) + charIndex = searchAndReplace(line, charIndex, strings); +} + +int TTparser::searchAndReplace(TTstring &line, int startIndex, const StringArray &strings) { + int lineSize = line.size(); + if (startIndex >= lineSize) + return -1; + + for (uint idx = 0; idx < strings.size(); idx += 2) { + const CString &origStr = strings[idx]; + const CString &replacementStr = strings[idx + 1]; + + if (!strncmp(line.c_str() + startIndex, origStr.c_str(), strings[idx].size())) { + // Ensure that that a space follows the match, or the end of string, + // so the end of the string doesn't match on parts of larger words + char c = line[startIndex + strings[idx].size()]; + if (c == ' ' || c == '\0') { + // Replace the text in the line with it's replacement + line = CString(line.c_str(), line.c_str() + startIndex) + replacementStr + + CString(line.c_str() + startIndex + origStr.size()); + + startIndex += replacementStr.size(); + break; + } + } + } + + // Skip to the end of the current word + while (startIndex < lineSize && line[startIndex] != ' ') + ++startIndex; + if (startIndex == lineSize) + return -1; + + // ..and all spaces following it until the start of the next word + while (startIndex < lineSize && line[startIndex] == ' ') + ++startIndex; + if (startIndex == lineSize) + return -1; + + // Return index of the start of the next word + return startIndex; +} + +int TTparser::replaceNumbers(TTstring &line, int startIndex) { + int index = startIndex; + const NumberEntry *numEntry = replaceNumbers2(line, &index); + if (!numEntry || !(numEntry->_flags & NF_2)) + return index; + + bool flag1 = false, flag2 = false, flag3 = false; + int total = 0, factor = 0; + + do { + if (numEntry->_flags & NF_1) { + flag2 = true; + if (numEntry->_flags & NF_8) + flag1 = true; + + if (numEntry->_flags & NF_4) { + flag3 = true; + factor *= numEntry->_value; + } + + if (numEntry->_flags & NF_2) { + if (flag3) { + total += factor; + factor = 0; + } + + factor += numEntry->_value; + } + } + } while (replaceNumbers2(line, &index)); + + if (!flag2) + return index; + + if (index >= 0) { + if (line[index - 1] != ' ') + return index; + } + + total += factor; + CTrueTalkManager::_v1 = total; + if (flag1) + total = -total; + + CString numStr = CString::format("%d", total); + line = CString(line.c_str(), line.c_str() + startIndex) + numStr + + CString(line.c_str() + index); + return index; +} + +const NumberEntry *TTparser::replaceNumbers2(TTstring &line, int *startIndex) { + int lineSize = line.size(); + int index = *startIndex; + if (index < 0 || index >= lineSize) { + *startIndex = -1; + return nullptr; + } + + NumberEntry *numEntry = nullptr; + + for (uint idx = 0; idx < _numbers.size(); ++idx) { + NumberEntry &ne = _numbers[idx]; + if (!strncmp(line.c_str() + index, ne._text.c_str(), ne._text.size())) { + if ((ne._flags & NF_10) || (index + (int)ne._text.size()) >= lineSize || + line[index + ne._text.size()] == ' ') { + *startIndex += ne._text.size(); + numEntry = ≠ + break; + } + } + } + + if (!numEntry || !(numEntry->_flags & NF_10)) { + // Skip to end of current word + while (*startIndex < lineSize && !Common::isSpace(line[*startIndex])) + ++*startIndex; + } + + // Skip over following spaces until start of following word is reached + while (*startIndex < lineSize && Common::isSpace(line[*startIndex])) + ++*startIndex; + + if (*startIndex >= lineSize) + *startIndex = -1; + + return numEntry; +} + +int TTparser::findFrames(TTsentence *sentence) { + _sentenceConcept = &sentence->_sentenceConcept; + _sentence = sentence; + + TTstring *line = sentence->_normalizedLine.copy(); + TTstring wordString; + int status = 0; + for (int ctr = 1; !status; ++ctr) { + // Keep stripping words off the start of the passed input + wordString = line->tokenize(" \n"); + if (wordString.empty()) + break; + + TTword *srcWord = nullptr; + TTword *word = _owner->_vocab->getWord(wordString, &word); + sentence->storeVocabHit(srcWord); + + if (!word && ctr == 1) { + word = new TTword(wordString, WC_UNKNOWN, 0); + } + + for (TTword *currP = word; currP && !status; currP = currP->_nextP) + status = processRequests(currP); + + word->deleteSiblings(); + delete word; + } + + if (!status) { + status = checkForAction(); + } + + delete line; + return status; +} + +int TTparser::loadRequests(TTword *word) { + int status = 0; + + if (word->_tag != MKTAG('Z', 'Z', 'Z', 'T')) + addNode(word->_tag); + + switch (word->_wordClass) { + case WC_UNKNOWN: + break; + + case WC_ACTION: + if (word->_id != 0x70 && word->_id != 0x71) + addNode(1); + addNode(17); + + switch (word->_id) { + case 101: + case 110: + addNode(5); + addNode(4); + break; + + case 102: + addNode(4); + break; + + case 103: + case 111: + addNode(8); + addNode(7); + addNode(5); + addNode(4); + break; + + case 104: + case 107: + addNode(15); + addNode(5); + addNode(4); + break; + + case 106: + addNode(7); + addNode(4); + break; + + case 108: + addNode(5); + addNode(4); + addNode(23); + break; + + case 112: + case 113: + addNode(13); + addNode(5); + break; + + default: + break; + } + + if (_sentenceConcept) { + if (_sentenceConcept->get18() == 0 || _sentenceConcept->get18() == 2) { + TTaction *action = static_cast<TTaction *>(word); + _sentenceConcept->set18(action->getVal()); + } + } + break; + + case WC_THING: + if (word->checkTag() && _sentence->_field58 > 0) + _sentence->_field58--; + addNode(14); + break; + + case WC_ABSTRACT: + switch (word->_id) { + case 300: + addNode(14); + status = 1; + break; + + case 306: + addNode(23); + addNode(4); + break; + + case 307: + case 308: + addNode(23); + break; + + default: + break; + } + + if (status != 1) { + addToConceptList(word); + addNode(14); + } + break; + + case WC_ARTICLE: + addNode(2); + status = 1; + break; + + case WC_CONJUNCTION: + if (_sentence->check2C()) { + _sentenceConcept->_field1C = 1; + _sentenceConcept = _sentenceConcept->addSibling(); + delete this; + } else { + addNode(23); + } + break; + + case WC_PRONOUN: + status = fn2(word); + break; + + case WC_PREPOSITION: + switch (word->_id) { + case 700: + addNode(6); + addNode(5); + break; + case 701: + addNode(11); + break; + case 702: + status = 1; + break; + case 703: + addNode(9); + break; + case 704: + addNode(10); + break; + default: + break; + } + + case WC_ADJECTIVE: + if (word->_id == 304) { + // Nothing + } else if (word->_id == 801) { + addNode(22); + } else { + if (word->proc16()) + _sentence->_field58++; + if (word->proc17()) + _sentence->_field58++; + } + break; + + case WC_ADVERB: + switch (word->_id) { + case 900: + case 901: + case 902: + case 904: + if (_sentence->_field2C == 9) { + _sentenceConcept->_field1C = 1; + _sentenceConcept = _sentenceConcept->addSibling(); + addNode(1); + } + else { + addNode(23); + addNode(13); + addNode(1); + } + break; + + case 905: + case 907: + case 908: + case 909: + addNode(23); + break; + + case 906: + addNode(23); + status = 1; + break; + + case 910: + addNode(4); + addNode(24); + addNode(23); + addNode(14); + status = 1; + break; + + default: + break; + } + + if (word->_id == 906) { + addNode(14); + status = 1; + } + break; + + default: + break; + } + + return status; +} + +int TTparser::considerRequests(TTword *word) { + if (!_nodesP || !word) + return 0; + + TTconcept *concept = nullptr; + int status = 0; + bool flag = false; + bool modifierFlag = false; + int seekVal = 0; + + for (TTparserNode *nodeP = _nodesP; nodeP; ) { + switch (nodeP->_tag) { + case CHECK_COMMAND_FORM: + if (_sentenceConcept->_concept1P && _sentence->_field2C == 1 && + !_sentenceConcept->_concept0P) { + concept = new TTconcept(_sentence->_npcScript, ST_NPC_SCRIPT); + _sentenceConcept->_concept0P = concept; + _sentenceConcept->_field18 = 3; + } + + flag = true; + break; + + case EXPECT_THING: + if (!word->_wordClass) { + word->_wordClass = WC_THING; + addToConceptList(word); + addNode(14); + } + + flag = true; + break; + + case OBJECT_IS_TO: + flag = resetConcept(&_sentenceConcept->_concept2P, 3); + break; + + case SEEK_ACTOR: + case MKTAG('S', 'A', 'C', 'T'): + if (!_sentenceConcept->_concept0P) { + flag = filterConcepts(5, 0); + } else if (_sentenceConcept->_concept0P->compareTo("?") && + _sentenceConcept->_concept1P->isWordId(113) && + word->_wordClass == WC_THING) { + TTconcept *oldConcept = _sentenceConcept->_concept0P; + _sentenceConcept->_concept0P = nullptr; + flag = filterConcepts(5, 2); + if (flag) + delete oldConcept; + } else { + flag = true; + } + break; + + case SEEK_OBJECT: + if (_sentenceConcept->_concept2P && _sentenceConcept->_concept2P->compareTo(word)) { + flag = true; + } else if (!_sentenceConcept->_concept2P) { + if (filterConcepts(5, 2) && _sentenceConcept->_concept2P->checkWordId1()) + addNode(5); + } else if (word->_wordClass == WC_THING && _sentence->fn2(2, TTstring("?"), _sentenceConcept)) { + TTconcept *oldConcept = _sentenceConcept->_concept2P; + flag = filterConcepts(5, 2); + _sentenceConcept->_concept2P->_field20 = oldConcept->get20(); + if (flag) + delete oldConcept; + } else if (!_sentenceConcept->_concept3P && + (!_sentenceConcept->_concept1P || (_sentenceConcept->_concept1P->getWordId() && + _sentenceConcept->_concept1P->getWordId() == 112)) && + _sentenceConcept->_concept2P->checkWordId1() && + (word->_wordClass == WC_THING || word->_wordClass == WC_PRONOUN)) { + _sentenceConcept->changeConcept(0, &_sentenceConcept->_concept2P, 3); + + if (_conceptP && _conceptP->isWordId(word->_id)) { + status = _sentenceConcept->replaceConcept(0, 2, _conceptP); + removeConcept(_conceptP); + } else { + status = _sentenceConcept->createConcept(0, 2, word); + } + + if (!status && !_sentenceConcept->_concept4P && _sentenceConcept->_concept0P) { + TTconcept *oldConcept = _sentenceConcept->_concept2P; + flag = filterConcepts(5, 2); + _sentenceConcept->_concept2P->_field20 = oldConcept->get20(); + if (flag) + delete oldConcept; + } else { + flag = true; + } + } + break; + + case SEEK_OBJECT_OVERRIDE: + if ((word->_wordClass == WC_THING || word->_wordClass == WC_PRONOUN) && + _sentence->fn2(2, TTstring("thePlayer"), _sentenceConcept) && + !_sentenceConcept->_concept3P) { + _sentenceConcept->_concept3P = _sentenceConcept->_concept2P; + _sentenceConcept->_concept2P = nullptr; + + flag = filterConcepts(5, 2); + if (!flag) { + status = _sentenceConcept->createConcept(0, 2, word); + } + } + break; + + case SEEK_TO: + if (!_sentenceConcept->_concept3P) { + if (!filterConcepts(8, 3)) + flag = filterConcepts(3, 3); + } else { + flag = true; + } + break; + + case SEEK_FROM: + if (!_sentenceConcept->_concept4P) { + if (!filterConcepts(8, 4)) + flag = filterConcepts(3, 3); + } else { + flag = true; + } + break; + + case SEEK_TO_OVERRIDE: + if (word->_wordClass == WC_ACTION) { + status = _sentenceConcept->createConcept(0, 1, word); + if (!status) { + seekVal = _sentenceConcept->_field18; + _sentenceConcept->_field18 = 4; + flag = true; + } + } else if (word->_id == 703) { + if (_sentenceConcept->_concept2P) { + delete _sentenceConcept->_concept2P; + _sentenceConcept->_concept2P = nullptr; + } + + if (_sentenceConcept->_concept4P || !_sentenceConcept->_concept0P) { + addNode(7); + } else { + _sentenceConcept->changeConcept(1, &_sentenceConcept->_concept0P, 4); + concept = nullptr; + addNode(7); + } + } else { + flag = true; + } + break; + + case SEEK_FROM_OVERRIDE: + if (_sentenceConcept->_concept4P) { + delete _sentenceConcept->_concept4P; + _sentenceConcept->_concept4P = nullptr; + } + + addNode(8); + flag = true; + break; + + case SEEK_LOCATION: + addNode(5); + _sentenceConcept->createConcept(0, 5, word); + flag = true; + break; + + case SEEK_OWNERSHIP: + if (word->_id == 601) { + if (_conceptP->findByWordClass(WC_THING)) + status = _conceptP->setOwner(word, false); + + flag = true; + } + break; + + case SEEK_STATE: + if (_sentenceConcept->_concept5P) { + if (_sentenceConcept->_concept5P->findByWordId(306) || + _sentenceConcept->_concept5P->findByWordId(904)) { + TTconcept *oldConcept = _sentenceConcept->_concept5P; + _sentenceConcept->_concept5P = nullptr; + flag = filterConcepts(9, 5); + if (flag) + delete oldConcept; + } else { + flag = true; + } + } else { + flag = filterConcepts(9, 5); + if (!flag && word->_wordClass == WC_ADVERB) { + status = _sentenceConcept->createConcept(1, 5, word); + flag = true; + } + } + break; + + case SEEK_MODIFIERS: + if (!modifierFlag) { + bool tempFlag = false; + + switch (word->_wordClass) { + case WC_ACTION: + status = processModifiers(1, word); + break; + case WC_THING: + status = processModifiers(2, word); + break; + case WC_ABSTRACT: + if (word->_id != 300) { + status = processModifiers(3, word); + } else if (!_conceptP->findByWordClass(WC_THING)) { + status = processModifiers(3, word); + } else { + word->_id = atoi(word->_text.c_str()); + } + break; + case WC_PRONOUN: + if (word->_id != 602) + addToConceptList(word); + break; + case WC_ADJECTIVE: { + TTconcept *conceptP = _conceptP->findByWordClass(WC_THING); + if (conceptP) { + conceptP->_string2 += ' '; + conceptP->_string2 += word->getText(); + } else { + status = processModifiers(8, word); + } + break; + } + case WC_ADVERB: + if (word->_id == 906) { + for (TTconcept *currP = _conceptP; currP; currP = currP->_nextP) { + if (_sentence->isFrameSlotClass(1, WC_ACTION) || + _sentence->isFrameSlotClass(1, WC_THING)) + currP->_field34 = 1; + } + } else { + TTconcept *conceptP = _conceptP->findByWordClass(WC_ACTION); + + if (conceptP) { + conceptP->_string2 += ' '; + conceptP->_string2 += word->getText(); + } else { + tempFlag = true; + } + } + break; + default: + addToConceptList(word); + status = 0; + break; + } + + if (tempFlag) + status = _sentenceConcept->createConcept(1, 5, word); + + modifierFlag = true; + flag = true; + } + break; + + case SEEK_NEW_FRAME: + if (word->_wordClass == WC_ACTION && word->_id != 104 && word->_id != 107) { + if (concept && (_sentenceConcept->_concept5P || _sentenceConcept->_concept2P)) { + TTsentenceConcept *oldNode = _sentenceConcept; + oldNode->_field1C = 2; + _sentenceConcept = oldNode->addSibling(); + concept = nullptr; + + _sentenceConcept->_concept1P = oldNode->_concept1P; + _sentenceConcept->_concept5P = oldNode->_concept5P; + _sentenceConcept->_concept2P = oldNode->_concept2P; + + if (seekVal) { + seekVal = 0; + + _sentenceConcept->_field18 = oldNode->_field18; + oldNode->_field18 = seekVal; + } + } + + flag = true; + } + break; + + case SEEK_STATE_OBJECT: + if (!_sentenceConcept->_concept5P) { + addToConceptList(word); + } else if (_sentenceConcept->concept5WordId() == 113 || + _sentenceConcept->concept5WordId() == 112) { + _sentenceConcept->createConcept(1, 2, word); + } else { + addToConceptList(word); + } + + flag = true; + break; + + case SET_ACTION: + if (_sentence->fn4(1, 104, _sentenceConcept) || + _sentence->fn4(1, 107, _sentenceConcept)) { + concept = _sentenceConcept->_concept1P; + _sentenceConcept->_concept1P = nullptr; + addNode(15); + } + + if (_sentence->check2C() && word->_id == 113) + addNode(4); + + if (word->_wordClass == WC_ACTION) + _sentenceConcept->createConcept(0, 1, word); + + flag = true; + break; + + case ACTOR_IS_TO: + _sentenceConcept->changeConcept(1, &_sentenceConcept->_concept0P, 3); + flag = true; + break; + + case ACTOR_IS_FROM: + _sentenceConcept->changeConcept(1, &_sentenceConcept->_concept0P, 4); + break; + + case ACTOR_IS_OBJECT: + flag = resetConcept(&_sentenceConcept->_concept0P, 2); + break; + + case WORD_TYPE_IS_SENTENCE_TYPE: + if (_sentence->_field2C == 1 || _sentence->_field2C == 10) { + for (TTword *wordP = _currentWordP; wordP; wordP = wordP->_nextP) { + if (wordP->_id == 906) { + _sentence->_field2C = 12; + flag = true; + break; + } + } + + TTpicture *newPictP; + TTconcept *newConceptP; + switch (word->_id) { + case 108: + _sentence->_field2C = 8; + break; + case 113: + if (!_sentenceConcept->_concept3P) + _sentence->_field2C = 22; + break; + case 304: + _sentence->_field2C = 25; + break; + case 305: + _sentence->_field2C = 24; + break; + case 306: + _sentence->_field2C = 7; + break; + case 501: + _sentence->_field2C = 9; + break; + case 900: + _sentence->_field2C = 5; + break; + case 901: + _sentence->_field2C = 4; + break; + case 904: + _sentence->_field2C = 6; + break; + case 905: + _sentence->_field2C = 11; + break; + case 906: + _sentence->_field2C = 12; + break; + case 907: + _sentence->_field2C = 13; + break; + case 908: + _sentence->_field2C = 2; + if (!_sentenceConcept->_concept0P) { + newPictP = new TTpicture(TTstring("?"), WC_THING, 0, 0, 0, 0, 0); + newConceptP = new TTconcept(newPictP); + + _sentenceConcept->_concept0P = newConceptP; + delete newPictP; + addNode(4); + } + break; + case 909: + _sentence->_field2C = 3; + newPictP = new TTpicture(TTstring("?"), WC_THING, 0, 0, 0, 0, 0); + newConceptP = new TTconcept(newPictP); + + _sentenceConcept->_concept2P = newConceptP; + delete newPictP; + addNode(4); + break; + + default: + break; + } + } + + flag = true; + break; + + case COMPLEX_VERB: + if (word->_wordClass == WC_ACTION) { + flag = true; + } else if (!_sentenceConcept->_concept1P) { + TTstring wordStr = word->getText(); + if (wordStr == "do" || wordStr == "doing" || wordStr == "does" || wordStr == "done") { + TTaction *verbP = new TTaction(TTstring("do"), WC_ACTION, 112, 0, + _sentenceConcept->get18()); + status = _sentenceConcept->createConcept(1, 1, verbP); + delete verbP; + } + + flag = true; + } + break; + + case MKTAG('C', 'O', 'M', 'E'): + addNode(7); + addNode(5); + addNode(21); + + if (!_sentence->_field2C) + _sentence->_field2C = 15; + break; + + case MKTAG('C', 'U', 'R', 'S'): + case MKTAG('S', 'E', 'X', 'X'): + if (_sentence->_field58 > 1) + _sentence->_field58--; + flag = true; + break; + + case MKTAG('E', 'X', 'I', 'T'): + addNode(8); + addNode(5); + addNode(21); + + if (!_sentence->_field2C) + _sentence->_field2C = 14; + break; + + case MKTAG('F', 'A', 'R', 'R'): + if (_conceptP->findBy20(0)) + _conceptP->_field20 = 2; + break; + + case MKTAG('F', 'U', 'T', 'R'): + _sentenceConcept->_field18 = 3; + break; + + case MKTAG('G', 'O', 'G', 'O'): + addNode(7); + addNode(5); + addNode(21); + + if (_sentence->_field2C == 1) + _sentence->_field2C = 14; + + flag = true; + break; + + case MKTAG('H', 'E', 'L', 'P'): + if (_sentence->_field2C == 1) + _sentence->_field2C = 18; + + flag = true; + break; + + case MKTAG('L', 'O', 'C', 'F'): + status = _sentenceConcept->createConcept(1, 5, word); + if (!status) + _sentenceConcept->_concept5P->_field20 = 2; + + flag = true; + break; + + case MKTAG('L', 'O', 'C', 'N'): + status = _sentenceConcept->createConcept(1, 5, word); + if (!status) + _sentenceConcept->_concept5P->_field20 = 1; + + flag = true; + break; + + case MKTAG('N', 'E', 'A', 'R'): + if (_conceptP->findBy20(0)) { + _conceptP->_field20 = 1; + } else { + TTpicture *newPictP = new TTpicture(TTstring("?"), WC_THING, 0, 0, 0, 0, 0); + status = addToConceptList(newPictP); + _conceptP->_field20 = 1; + if (!status) + delete newPictP; + } + + flag = true; + break; + + case MKTAG('P', 'A', 'S', 'T'): + _sentenceConcept->_field18 = 1; + flag = true; + break; + + case MKTAG('P', 'L', 'E', 'Z'): + if (_sentence->_field58 < 10) + _sentence->_field58++; + break; + + case MKTAG('P', 'R', 'E', 'Z'): + _sentenceConcept->_field18 = 2; + flag = true; + break; + + case MKTAG('S', 'A', 'A', 'O'): + addNode(5); + addNode(4); + flag = true; + break; + + case MKTAG('S', 'S', 'T', 'A'): + addNode(13); + addNode(5); + flag = true; + break; + + case MKTAG('T', 'E', 'A', 'C'): + if (_sentence->_field2C == 1) + _sentence->_field2C = 10; + + flag = true; + break; + + case MKTAG('V', 'O', 'B', 'J'): + status = _sentenceConcept->createConcept(1, 2, word); + flag = true; + break; + + default: + flag = true; + break; + } + + TTparserNode *nextP = static_cast<TTparserNode *>(nodeP->_nextP); + if (flag) + delete nodeP; + nodeP = nextP; + } + + delete concept; + return status; +} + +int TTparser::processRequests(TTword *word) { + int status = loadRequests(word); + switch (status) { + case 0: + status = considerRequests(word); + + // Iterate through the words + while (_currentWordP) { + considerRequests(_currentWordP); + TTword *nextP = _currentWordP->_nextP; + + delete _currentWordP; + _currentWordP = nextP; + } + break; + + case 1: { + TTword *newWord = new TTword(word); + newWord->_nextP = nullptr; + + // Add word to word chain + if (_currentWordP) { + // Add at end of existing chain + for (word = _currentWordP; word->_nextP; word = word->_nextP) + ; + word->_nextP = newWord; + } else { + // First word, so set as head + _currentWordP = newWord; + } + break; + } + + default: + warning("unexpected return from consider requests"); + break; + } + + return status; +} + +int TTparser::addToConceptList(TTword *word) { + TTconcept *concept = new TTconcept(word, ST_UNKNOWN_SCRIPT); + addConcept(concept); + return 0; +} + +void TTparser::addNode(uint tag) { + TTparserNode *newNode = new TTparserNode(tag); + if (_nodesP) + _nodesP->addToHead(newNode); + _nodesP = newNode; +} + +int TTparser::addConcept(TTconcept *concept) { + if (!concept) + return SS_5; + + if (_conceptP) + concept->_nextP = _conceptP; + _conceptP = concept; + + return SS_VALID; +} + +void TTparser::removeConcept(TTconcept *concept) { + // If no concept passed, exit immediately + if (!concept) + return; + + if (_conceptP == concept) { + // Concept specified is the ver ystart of the linked list, so reset head pointer + _conceptP = _conceptP->_nextP; + } else { + // Scan through the linked list, looking for the specific concept + for (TTconcept *currP = _conceptP; currP; currP = currP->_nextP) { + if (currP->_nextP == concept) { + // Found match, so unlink the next link from the chain + currP->_nextP = currP->_nextP->_nextP; + break; + } + } + } + + // FInally, delete the concept + concept->_nextP = nullptr; + delete concept; +} + +void TTparser::removeNode(TTparserNode *node) { + if (!node->_priorP) + // Node is the head of the chain, so reset parser's nodes pointer + _nodesP = static_cast<TTparserNode *>(node->_nextP); + + delete node; +} + +int TTparser::checkForAction() { + int status = SS_VALID; + bool flag = false; + bool actionFlag = false; + + if (_conceptP && _currentWordP) { + // Firstly we need to get the next word to process, and remove it from + // the list pointed to by _currentWordP + TTword *word = _currentWordP; + if (word->_nextP) { + // Chain of words, so we need to find the last word of the chain, + // and set the last-but-one's _nextP to nullptr to detach the last one + TTword *prior = nullptr; + for (word = word->_nextP; word->_nextP; word = word->_nextP) { + prior = word; + } + + if (prior) + prior->_nextP = nullptr; + } else { + // No chain, so singular word can simply be removed + _currentWordP = nullptr; + if (word->_id == 906 && _sentence->_field2C == 1) + _sentence->_field2C = 12; + } + + if (word->_text == "do" || word->_text == "doing" || word->_text == "does" || + word->_text == "done") { + TTstring doStr("do"); + TTaction *action = new TTaction(doStr, WC_ACTION, 112, 0, _sentenceConcept->get18()); + + if (!action->isValid()) { + status = SS_4; + } else { + // Have the new action replace the old word instance + delete word; + word = action; + actionFlag = true; + } + } + + addToConceptList(word); + delete word; + flag = true; + } + + // Handle any remaining words + while (_currentWordP) { + int result = considerRequests(_currentWordP); + if (result > 1) { + status = result; + } else { + // Delete the top of the word chain + TTword *wordP = _currentWordP; + _currentWordP = _currentWordP->_nextP; + delete wordP; + } + } + + if (flag && _conceptP) { + if (actionFlag && (!_sentenceConcept->_concept1P || _sentenceConcept->_concept1P->isWordId(113))) { + _sentenceConcept->replaceConcept(0, 1, _conceptP); + } else if (!_sentenceConcept->_concept5P) { + _sentenceConcept->replaceConcept(1, 5, _conceptP); + } else if (_sentenceConcept->_concept5P->isWordId(904)) { + _sentenceConcept->replaceConcept(0, 5, _conceptP); + } + + removeConcept(_conceptP); + } + + if (_sentence->fn2(3, TTstring("thePlayer"), _sentenceConcept) && !flag) { + if (_sentenceConcept->concept1WordId() == 101) { + _sentence->_field2C = 16; + } else if (_sentence->_field2C != 18 && _sentenceConcept->concept1WordId() == 102) { + if (_sentence->fn2(0, TTstring("targetNpc"), _sentenceConcept)) + _sentence->_field2C = 15; + } + } + + if (_sentence->fn2(2, TTstring("thePlayer"), _sentenceConcept) && + _sentenceConcept->concept1WordId() == 101 && flag) + _sentence->_field2C = 17; + + if (!_sentenceConcept->_concept0P && !_sentenceConcept->_concept1P && + !_sentenceConcept->_concept2P && !_sentenceConcept->_concept5P && !flag) { + if (_conceptP) + filterConcepts(5, 2); + + if (!_sentenceConcept->_concept2P && _sentence->_field2C == 1) + _sentence->_field2C = 0; + } + + if (_sentence->_field58 < 5 && _sentence->_field2C == 1 && !flag) + _sentence->_field2C = 19; + + for (TTconceptNode *nodeP = &_sentence->_sentenceConcept; nodeP; nodeP = nodeP->_nextP) { + if (nodeP->_field18 == 0 && nodeP->_concept1P) { + nodeP->_field18 = _sentence->concept18(nodeP); + } else if (nodeP->_field18 == 4 && !_sentenceConcept->_concept0P) { + if (_sentenceConcept->_concept3P) { + _sentenceConcept->_concept0P = _sentenceConcept->_concept3P; + _sentenceConcept->_concept3P = nullptr; + } else if (_sentenceConcept->_concept2P) { + _sentenceConcept->_concept0P = _sentenceConcept->_concept2P; + _sentenceConcept->_concept2P = nullptr; + } + } + } + + if (_sentence->_field2C == 1 && _sentenceConcept->_concept5P && + _sentenceConcept->_concept2P) { + if (_sentence->fn4(1, 113, nullptr)) { + if (_sentence->fn2(2, TTstring("targetNpc"), nullptr)) { + _sentence->_field2C = 20; + } else if (_sentence->fn2(2, TTstring("thePlayer"), nullptr)) { + _sentence->_field2C = 21; + } else { + _sentence->_field2C = 22; + } + } + } else if (!_sentenceConcept->_concept0P && !_sentenceConcept->_concept1P && + !_sentenceConcept->_concept2P && !_sentenceConcept->_concept5P) { + if (_conceptP) + filterConcepts(5, 2); + + if (!_sentenceConcept->_concept2P && _sentence->_field2C == 1) + _sentence->_field2C = 0; + } + + return status; +} + +int TTparser::fn2(TTword *word) { + switch (word->_id) { + case 600: + addNode(13); + return 0; + + case 601: + addNode(12); + return 1; + + case 602: + case 607: + return checkReferent(static_cast<TTpronoun *>(word)); + + case 608: + return 1; + + default: + return 0; + } +} + +int TTparser::checkReferent(TTpronoun *pronoun) { + TTconcept *concept; + + switch (pronoun->getVal()) { + case 0: + return 0; + + case 1: + concept = new TTconcept(_owner->_script, ST_ROOM_SCRIPT); + break; + + case 2: + concept = new TTconcept(_sentence->_npcScript, ST_NPC_SCRIPT); + break; + + default: + concept = new TTconcept(pronoun, (ScriptType)pronoun->getVal()); + break; + } + + addConcept(concept); + return 0; +} + +void TTparser::conceptChanged(TTconcept *newConcept, TTconcept *oldConcept) { + if (!oldConcept && newConcept != _currentConceptP) + _currentConceptP = nullptr; + else if (oldConcept && oldConcept == _currentConceptP) + _currentConceptP = newConcept; +} + +bool TTparser::checkConcept2(TTconcept *concept, int conceptMode) { + switch (conceptMode) { + case 3: + return concept->checkWordId2(); + + case 5: + return concept->checkWordClass(); + + case 8: + return concept->checkWordId1(); + + case 9: + if (!concept->checkWordId3() && _sentenceConcept->_concept2P) { + if (!_sentenceConcept->_concept2P->checkWordId2() || !concept->checkWordId2()) { + return _sentenceConcept->_concept2P->checkWordClass() && + concept->checkWordClass(); + } + } + break; + + default: + break; + } + + return false; +} + +int TTparser::filterConcepts(int conceptMode, int conceptIndex) { + int result = 0; + + for (TTconcept *currP = _conceptP; currP && !result; currP = currP->_nextP) { + if (checkConcept2(currP, conceptMode)) { + TTconcept **ptrPP = _sentenceConcept->setConcept(conceptIndex, currP); + TTconcept *newConcept = new TTconcept(*currP); + *ptrPP = newConcept; + + if (newConcept->isValid()) { + removeConcept(currP); + (*ptrPP)->_nextP = nullptr; + result = 1; + } else { + result = -2; + } + } + } + + return result; +} + +bool TTparser::resetConcept(TTconcept **conceptPP, int conceptIndex) { + TTconcept **ptrPP = _sentenceConcept->setConcept(conceptIndex, nullptr); + + if (!*ptrPP) + return 0; + + int result = _sentenceConcept->changeConcept(1, conceptPP, conceptIndex); + if (*conceptPP) + _sentenceConcept->setConcept(conceptIndex, *conceptPP); + + return !result; +} + +int TTparser::processModifiers(int modifier, TTword *word) { + TTconcept *newConcept = new TTconcept(word, ST_UNKNOWN_SCRIPT); + + // Cycles through each word + for (TTword *currP = _currentWordP; currP != word; currP = _currentWordP) { + if ((modifier == 2 && currP->_wordClass == WC_ADJECTIVE) || + (modifier == 1 && currP->_wordClass == WC_ADVERB)) { + newConcept->_string2 += ' '; + newConcept->_string2 += _currentWordP->getText(); + } else if (word->_id == 113 && currP->_wordClass == WC_ADJECTIVE) { + addToConceptList(currP); + addNode(13); + } + + if (modifier == 2 || modifier == 3) { + switch (_currentWordP->_id) { + case 94: + _currentConceptP->setOwner(newConcept); + if (_currentWordP) { + _currentWordP->deleteSiblings(); + delete _currentWordP; + _currentWordP = nullptr; + } + + delete newConcept; + newConcept = nullptr; + break; + + case 204: + newConcept->_field34 = 1; + if (_sentence->_field2C == 1) + _sentence->_field2C = 12; + newConcept->_field14 = 1; + break; + + case 300: + newConcept->set1C(atoi(_currentWordP->_text.c_str())); + break; + + case 400: + newConcept->_field14 = 2; + break; + + case 401: + newConcept->_field14 = 1; + break; + + case 601: + newConcept->setOwner(_currentWordP, false); + break; + + case 608: + if (_currentWordP->comparePronounTo(10)) { + newConcept->_field20 = 1; + } else if (_currentWordP->comparePronounTo(11)) { + newConcept->_field20 = 2; + } + + default: + break; + } + } + + if (_currentWordP) { + // Detaches word and deletes it + TTword *wordP = _currentWordP; + _currentWordP = wordP->_nextP; + + wordP->_nextP = nullptr; + delete wordP; + } + } + + if (newConcept) { + newConcept->setFlag(true); + _currentConceptP = newConcept; + addConcept(newConcept); + } + + return 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_parser.h b/engines/titanic/true_talk/tt_parser.h new file mode 100644 index 0000000000..201de7eb0e --- /dev/null +++ b/engines/titanic/true_talk/tt_parser.h @@ -0,0 +1,208 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_PARSER_H +#define TITANIC_TT_PARSER_H + +#include "titanic/true_talk/tt_node.h" +#include "titanic/true_talk/tt_pronoun.h" +#include "titanic/true_talk/tt_sentence.h" +#include "titanic/true_talk/tt_string.h" + +namespace Titanic { + +enum NumberFlag { NF_1 = 1, NF_2 = 2, NF_4 = 4, NF_8 = 8, NF_10 = 0x10 }; + +enum ParserAction { + NO_ACTION = 0, CHECK_COMMAND_FORM, EXPECT_THING, OBJECT_IS_TO, + SEEK_ACTOR, SEEK_OBJECT, SEEK_OBJECT_OVERRIDE, SEEK_TO, + SEEK_FROM, SEEK_TO_OVERRIDE, SEEK_FROM_OVERRIDE, SEEK_LOCATION, + SEEK_OWNERSHIP, SEEK_STATE, SEEK_MODIFIERS, SEEK_NEW_FRAME, + SEEK_STATE_OBJECT, SET_ACTION, SET_COLOR, ACTOR_IS_TO, + ACTOR_IS_FROM, ACTOR_IS_OBJECT, STATE_IDENTITY, + WORD_TYPE_IS_SENTENCE_TYPE, COMPLEX_VERB +}; + +class CScriptHandler; +class TTconcept; + +struct NumberEntry { + CString _text; + int _value; + int _flags; + + NumberEntry() : _value(0), _flags(0) {} + NumberEntry(const CString &text, int value, int flags) : + _text(text), _value(value), _flags(flags) {} +}; +typedef Common::Array<NumberEntry> NumberArray; + +class TTparserNode : public TTnode { +public: + uint _tag; +public: + TTparserNode() : TTnode(), _tag(0) {} + TTparserNode(uint tag) : TTnode(), _tag(tag) {} +}; + +class TTparser { +private: + StringArray _replacements1; + StringArray _replacements2; + StringArray _replacements3; + StringArray _phrases; + NumberArray _numbers; + TTparserNode *_nodesP; + TTconcept *_conceptP; + TTconcept *_currentConceptP; +private: + /** + * Load the data for a given array resource + */ + void loadArray(StringArray &arr, const CString &name); + + /** + * Loads the various replacement string data arrays + */ + void loadArrays(); + + /** + * Normalizes a passed input, taking care of things like removing extra + * spaces and lowercasing everything + */ + int normalize(TTsentence *sentence); + + /** + * Submethod called by normalize to handle expanding contacted word pairs + * like can't, should've, and so on. + */ + bool normalizeContraction(const TTstring &srcLine, int srcIndex, TTstring &destLine); + + /** + * Checks for what is likely special developer cheat codes + */ + static int isEmoticon(const TTstring &str, int &index); + + /** + * Checks if any word within a passed line has an entry in the list of replacements, + * and if found, replaces it with it's equivalent replacement string + * @param line Line to check + * @param strings List of strings to check for. Strings come in pairs, with the + * first being the string to match, and the second the replacement + */ + static void searchAndReplace(TTstring &line, const StringArray &strings); + + /** + * Checks the string starting at a given index for any word in the passed string array, + * and if found, replaces it in the line with it's replacement + * @param line Line to check + * @param startIndex Starting index in the start to check + * @param strings List of strings to check for. Strings come in pairs, with the + * first being the string to match, and the second the replacement + * @returns Index of the start of the following word + */ + static int searchAndReplace(TTstring &line, int startIndex, const StringArray &strings); + + /** + * Checks the string starting at a given index for a number representation + * such as roman numericals, spelled out numbers, etc. and replaces it with + * a plain decimal representation. + * @param line Line to check + * @param startIndex Starting index in the start to check + * @returns Index of the start of the following word, or -1 if at end of line + */ + int replaceNumbers(TTstring &line, int startIndex); + + /** + * Checks the string starting at a given index for a number representation + * such as roman numericals, spelled out numbers, etc. and replaces it with + * a plain decimal representation. + * @param line Line to check + * @param startIndex Starting index in the start to check + * @returns Pointer to matching number entry, if match occurred + */ + const NumberEntry *replaceNumbers2(TTstring &line, int *startIndex); + + int loadRequests(TTword *word); + int considerRequests(TTword *word); + int processRequests(TTword *word); + + int addToConceptList(TTword *word); + int checkReferent(TTpronoun *pronoun); + + /** + * Creates a new parser node, and adds it to the parser's list + */ + void addNode(uint tag); + + /** + * Add a concept node + */ + int addConcept(TTconcept *concept); + + /** + * Detaches a concept from the main concept list if prseent, then deletes it + */ + void removeConcept(TTconcept *concept); + + /** + * Detaches a node from the main node list + */ + void removeNode(TTparserNode *node); + + int processModifiers(int modifier, TTword *word); + + int checkForAction(); + int fn2(TTword *word); + bool checkConcept2(TTconcept *concept, int conceptMode); + int filterConcepts(int conceptMode, int conceptIndex); + bool resetConcept(TTconcept **conceptPP, int conceptIndex); +public: + CScriptHandler *_owner; + TTsentenceConcept *_sentenceConcept; + TTsentence *_sentence; + int _fieldC; + int _field10; + int _field14; + TTword *_currentWordP; + StringArray _pronouns; +public: + TTparser(CScriptHandler *owner); + ~TTparser(); + + /** + * Preprocesses the passed input text, to handle things like lowercasing + * all the words, and replcaing common slang with their full equivalents + */ + int preprocess(TTsentence *sentence); + + int findFrames(TTsentence *sentence); + + /** + * Called when a concept is copied from one to another + */ + void conceptChanged(TTconcept *newConcept, TTconcept *oldConcept); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_PARSER_H */ diff --git a/engines/titanic/true_talk/tt_picture.cpp b/engines/titanic/true_talk/tt_picture.cpp new file mode 100644 index 0000000000..4b04b8825b --- /dev/null +++ b/engines/titanic/true_talk/tt_picture.cpp @@ -0,0 +1,102 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_picture.h" + +namespace Titanic { + +bool TTpicture::_staticFlag; + +TTpicture::TTpicture(const TTstring &str, WordClass wordClass, int val2, int val3, int val4, int val5, int val6) : + TTmajorWord(str, wordClass, val2, val4), _tag(val3), _field30(val5), _field3C(val6), + _field38(0) { +} + +TTpicture::TTpicture(const TTpicture *src) : TTmajorWord(src) { + if (getStatus()) { + _tag = 0; + _field30 = 0; + _field38 = 0; + _field3C = 0; + _status = SS_5; + } else { + _tag = src->_tag; + _field30 = src->_field30; + _field38 = src->_field38; + _field3C = src->_field3C; + } +} + +int TTpicture::load(SimpleFile *file) { + CString str; + int val1, val2; + + if (!TTword::load(file, WC_THING) && file->scanf("%s %d %d", &str, &val1, &val2)) { + _tag = readNumber(str.c_str()); + _field30 = val1; + _field3C = val2; + return 0; + } else { + return 3; + } +} + +TTword *TTpicture::copy() const { + TTpicture *returnWordP = new TTpicture(this); + returnWordP->_status = _status; + if (!_status) { + _staticFlag = false; + return returnWordP; + } else if (_status == SS_13 && !_staticFlag) { + _staticFlag = true; + delete returnWordP; + return copy(); + } else { + delete returnWordP; + return nullptr; + } +} + +bool TTpicture::checkTag() const { + return _tag == MKTAG('S', 'E', 'X', 'X') || + _tag == MKTAG('E', 'X', 'C', 'R') || + _tag == MKTAG('P', 'P', 'R', 'T') || + _tag == MKTAG('B', 'L', 'A', 'S'); +} + +bool TTpicture::compareTagTo(uint tag) const { + return _tag == tag; +} + +uint TTpicture::getTag() const { + return _tag; +} + +bool TTpicture::proc9(int val) const { + return _field3C == val; +} + +int TTpicture::proc10() const { + return _field3C; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_picture.h b/engines/titanic/true_talk/tt_picture.h new file mode 100644 index 0000000000..18cb88278f --- /dev/null +++ b/engines/titanic/true_talk/tt_picture.h @@ -0,0 +1,74 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_PICTURE_H +#define TITANIC_TT_PICTURE_H + +#include "titanic/true_talk/tt_major_word.h" + +namespace Titanic { + +class TTpicture : public TTmajorWord { +private: + static bool _staticFlag; +protected: + int _field30; + uint _tag; + int _field38; + int _field3C; +public: + TTpicture(const TTstring &str, WordClass wordClass, int val2, int val3, int val4, int val5, int val6); + TTpicture(const TTpicture *src); + + /** + * Load the word + */ + int load(SimpleFile *file); + + /** + * Creates a copy of the word + */ + virtual TTword *copy() const; + + /** + * Checks whether the word's tag is a known type + */ + virtual bool checkTag() const; + + /** + * Compare the word's tag to a given tag value + */ + virtual bool compareTagTo(uint tag) const; + + /** + * Return the tag associated with the word + */ + virtual uint getTag() const; + + virtual bool proc9(int val) const; + virtual int proc10() const; + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_PICTURE_H */ diff --git a/engines/titanic/true_talk/tt_pronoun.cpp b/engines/titanic/true_talk/tt_pronoun.cpp new file mode 100644 index 0000000000..3ef48314e6 --- /dev/null +++ b/engines/titanic/true_talk/tt_pronoun.cpp @@ -0,0 +1,73 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_pronoun.h" + +namespace Titanic { + +bool TTpronoun::_staticFlag; + +TTpronoun::TTpronoun(TTstring &str, WordClass wordClass, int val2, int val3, int val4) : + TTmajorWord(str, wordClass, val2, val3), _field30(val4) { +} + +TTpronoun::TTpronoun(const TTpronoun *src) : TTmajorWord(src) { + if (src->getStatus()) { + _field30 = 0; + _status = SS_5; + } else { + _field30 = src->_field30; + } +} + +int TTpronoun::load(SimpleFile *file) { + int val; + + if (!TTword::load(file, WC_PRONOUN) && file->scanf("%d", &val)) { + if (val >= 0 && val <= 12) { + _field30 = val; + return 0; + } else { + return 5; + } + } else { + return 8; + } +} + +TTword *TTpronoun::copy() const { + TTpronoun *returnWordP = new TTpronoun(this); + returnWordP->_status = _status; + if (!_status) { + _staticFlag = false; + return returnWordP; + } else if (_status == SS_13 && !_staticFlag) { + _staticFlag = true; + delete returnWordP; + return copy(); + } else { + delete returnWordP; + return nullptr; + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_pronoun.h b/engines/titanic/true_talk/tt_pronoun.h new file mode 100644 index 0000000000..ccc077152c --- /dev/null +++ b/engines/titanic/true_talk/tt_pronoun.h @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_PRONOUN_H +#define TITANIC_TT_PRONOUN_H + +#include "titanic/true_talk/tt_major_word.h" + +namespace Titanic { + +class TTpronoun : public TTmajorWord { +private: + static bool _staticFlag; +protected: + int _field30; +public: + TTpronoun(TTstring &str, WordClass wordClass, int val2, int val3, int val4); + TTpronoun(const TTpronoun *src); + + /** + * Load the word + */ + int load(SimpleFile *file); + + int getVal() const { return _field30; } + + /** + * Creates a copy of the word + */ + virtual TTword *copy() const; + + virtual bool comparePronounTo(int val) const { + return _field30 == val; + } + + /** + * Dumps data associated with the word to file + */ + virtual int save(SimpleFile *file) const { + return saveData(file, _field30); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_WORD_H */ diff --git a/engines/titanic/true_talk/tt_quotes.cpp b/engines/titanic/true_talk/tt_quotes.cpp new file mode 100644 index 0000000000..c690ac8780 --- /dev/null +++ b/engines/titanic/true_talk/tt_quotes.cpp @@ -0,0 +1,145 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/algorithm.h" +#include "titanic/true_talk/tt_quotes.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTquotes::TTquotes() : _loaded(false), _dataP(nullptr), _dataSize(0), + _field544(0) { + Common::fill(&_tags[0], &_tags[256], 0); +} + +TTquotes::~TTquotes() { + delete[] _dataP; +} + +void TTquotes::load() { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/JRQUOTES.TXT"); + size_t size = r->readUint32LE(); + _loaded = true; + + _dataSize = _field544 = size; + _dataP = new char[size + 0x10]; + + for (int idx = 0; idx < 256; ++idx) + _tags[idx] = r->readUint32LE(); + + for (int charIdx = 0; charIdx < 26; ++charIdx) { + TTquotesLetter &letter = _alphabet[charIdx]; + int count = r->readUint32LE(); + + // Load the list of entries for the given letter + letter._entries.resize(count); + for (int idx = 0; idx < count; ++idx) { + letter._entries[idx]._tagIndex = r->readByte(); + letter._entries[idx]._maxSize = r->readByte(); + letter._entries[idx]._strP = _dataP + r->readUint32LE(); + } + } + + // Read in buffer and then decode it + r->read((byte *)_dataP, _dataSize); + for (size_t idx = 0; idx < _dataSize; idx += 4) + WRITE_LE_UINT32((byte *)_dataP + idx, READ_LE_UINT32((const byte *)_dataP + idx) ^ 0xA55A5AA5); + + delete r; +} + +int TTquotes::find(const char *str) const { + if (!str || !*str) + return 0; + + // Find start and end of string + const char *startP = str, *endP = str; + while (*endP) + ++endP; + + do { + int tagId = find(startP, endP); + if (tagId) + return tagId; + + // Move to next following space or end of string + while (*startP && *startP != ' ') + ++startP; + // If it's a space, then move past it to start of next word + while (*startP && *startP == ' ') + ++startP; + + } while (*startP); + + // No match + return 0; +} + +int TTquotes::find(const char *startP, const char *endP) const { + int size = endP - startP; + if (size < 3) + return 0; + + uint index = MIN((uint)(*startP - 'a'), (uint)25); + const TTquotesLetter &letter = _alphabet[index]; + if (letter._entries.empty()) + // No entries for the letter, so exit immediately + return 0; + + int maxSize = size + 4; + + for (uint idx = 0; idx < letter._entries.size(); ++idx) { + const TTquotesEntry &entry = letter._entries[idx]; + if (entry._maxSize > maxSize) + continue; + + const char *srcP = startP; + const char *destP = entry._strP; + int srcIndex = index != 25 ? 1 : 0, destIndex = 0; + if (*destP) { + do { + if (!srcP[srcIndex]) { + break; + } else if (srcP[srcIndex] == '*') { + ++srcIndex; + } else if (destP[destIndex] == '-') { + ++destIndex; + if (srcP[srcIndex] == ' ') + ++srcIndex; + } else if (srcP[srcIndex] != destP[destIndex]) { + break; + } else { + ++destIndex; + ++srcIndex; + } + } while (destP[destIndex]); + + if (!destP[destIndex] && (srcP[srcIndex] <= '*' || + (srcP[srcIndex] == 's' && srcP[srcIndex + 1] <= '*'))) + return _tags[entry._tagIndex]; + } + } + + return 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_quotes.h b/engines/titanic/true_talk/tt_quotes.h new file mode 100644 index 0000000000..5958c9ebcf --- /dev/null +++ b/engines/titanic/true_talk/tt_quotes.h @@ -0,0 +1,77 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_QUOTES_H +#define TITANIC_TT_QUOTES_H + +#include "common/scummsys.h" +#include "common/stream.h" +#include "titanic/support/string.h" + +namespace Titanic { + +class TTquotes { + struct TTquotesEntry { + byte _tagIndex, _maxSize; + const char *_strP; + TTquotesEntry() : _tagIndex(0), _maxSize(0), _strP(nullptr) {} + }; + struct TTquotesLetter { + Common::Array<TTquotesEntry> _entries; + int _field4; + int _field8; + + TTquotesLetter() : _field4(0), _field8(0) {} + }; +private: + TTquotesLetter _alphabet[26]; + uint _tags[256]; + char *_dataP; + size_t _dataSize; + int _field544; +private: + /** + * Test whether a substring contains one of the quotes, + * and if so, returns the 4-character tag Id associated with it + */ + int find(const char *startP, const char *endP) const; +public: + bool _loaded; +public: + TTquotes(); + ~TTquotes(); + + /** + * Load quotes data resource + */ + void load(); + + /** + * Test whether a passed string contains one of the quotes, + * and if so, returns the 4-character tag Id associated with it + */ + int find(const char *str) const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_QUOTES_H */ diff --git a/engines/titanic/true_talk/tt_quotes_tree.cpp b/engines/titanic/true_talk/tt_quotes_tree.cpp new file mode 100644 index 0000000000..1f073b83f2 --- /dev/null +++ b/engines/titanic/true_talk/tt_quotes_tree.cpp @@ -0,0 +1,214 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/algorithm.h" +#include "titanic/true_talk/tt_quotes_tree.h" +#include "titanic/titanic.h" + +namespace Titanic { + +/** + * Specifies the starting index for each of the three main trees + */ +static uint TABLE_INDEXES[3] = { 922, 1015, 1018 }; + +void TTquotesTree::load() { + Common::SeekableReadStream *r = g_vm->_filesManager->getResource("TEXT/TREE"); + + for (int idx = 0; idx < QUOTES_TREE_COUNT; ++idx) { + TTquotesTreeEntry &rec = _entries[idx]; + assert(r->pos() < r->size()); + + rec._id = r->readUint32LE(); + if (rec._id == 0) { + // Nothing needed + } else { + byte type = r->readByte(); + if (type == 0) { + // Index to sub-table + rec._subTable = &_entries[0] + r->readUint32LE(); + } else { + // Read in string for entry + char c; + while ((c = r->readByte()) != '\0') + rec._string += c; + } + } + } + + assert(r->pos() == r->size()); + delete r; +} + +int TTquotesTree::search(const char *str, QuoteTreeNum treeNum, + TTtreeResult *buffer, uint tagId, uint *remainder) { + const TTquotesTreeEntry *bTree = &_entries[TABLE_INDEXES[treeNum]]; + if (!search1(&str, bTree, buffer, tagId) || !buffer->_treeItemP) + return -1; + + if (remainder) { + while (*str) { + if (*str >= 'a' && *str != 's') + *remainder += *str; + } + } + + return buffer->_treeItemP->_id & 0xffffff; +} + +bool TTquotesTree::search1(const char **str, const TTquotesTreeEntry *bTree, + TTtreeResult *buffer, uint tagId) { + buffer->_treeItemP = nullptr; + (buffer + 1)->_treeItemP = nullptr; + + const char *strP = *str; + bool flag = false; + + for (uint mode = bTree->_id >> 24; mode != 0; + ++bTree, mode = bTree->_id >> 24) { + + switch (mode) { + case 1: + if (compareWord(str, bTree->_string.c_str())) + flag = true; + break; + + case 2: + compareWord(str, bTree->_string.c_str()); + break; + + case 5: + if (READ_LE_UINT32(bTree->_string.c_str()) == tagId) + flag = true; + break; + + case 7: + if (search1(str, bTree->_subTable, buffer + 1, tagId)) + flag = true; + break; + + case 8: + if (search2(str, bTree->_subTable, buffer + 1, tagId)) + flag = true; + break; + + default: + break; + } + + if (flag) { + buffer->_treeItemP = bTree; + return true; + } + } + + *str = strP; + return false; +} + +bool TTquotesTree::search2(const char **str, const TTquotesTreeEntry *bTree, + TTtreeResult *buffer, uint tagId) { + buffer->_treeItemP = bTree; + (buffer + 1)->_treeItemP = nullptr; + + const char *strP = *str; + bool flag = false; + for (uint mode = bTree->_id >> 24; mode != 0; + ++bTree, mode = bTree->_id >> 24) { + switch (mode) { + case 0: + return true; + + case 1: + if (compareWord(str, bTree->_string.c_str())) + flag = true; + break; + + case 2: + compareWord(str, bTree->_string.c_str()); + break; + + case 5: + if (READ_LE_UINT32(bTree->_string.c_str()) == tagId) + flag = true; + break; + + case 7: + if (search1(str, bTree->_subTable, buffer + 1, tagId)) + flag = true; + break; + + case 8: + if (search2(str, bTree->_subTable, buffer + 1, tagId)) + flag = true; + break; + + default: + break; + } + + if (flag) { + buffer->_treeItemP = nullptr; + *str = strP; + return false; + } + } + + return true; +} + +bool TTquotesTree::compareWord(const char **str, const char *refStr) { + // Skip over any spaces + const char *strP = *str; + while (*strP && *strP == ' ') + ++strP; + *str = strP; + + // Compare against the reference string + while (*strP && *refStr && *refStr != '*') { + if (*refStr == '-') { + if (*strP == ' ') + ++strP; + } else if (*strP == *refStr) { + ++strP; + } else { + return false; + } + } + + if (*refStr && *refStr != '*') + return false; + if (!*refStr && *strP && *strP != ' ') + return false; + + if (*refStr == '*') { + // Skip over to the end of the word + while (*strP && *strP != ' ') + ++strP; + } + + // Pass out the new updated string position + *str = strP; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_quotes_tree.h b/engines/titanic/true_talk/tt_quotes_tree.h new file mode 100644 index 0000000000..d7ca798ae8 --- /dev/null +++ b/engines/titanic/true_talk/tt_quotes_tree.h @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_QUOTES_TREE_H +#define TITANIC_TT_QUOTES_TREE_H + +#include "common/scummsys.h" +#include "common/stream.h" +#include "titanic/support/string.h" + +namespace Titanic { + +#define QUOTES_TREE_COUNT 1022 + +enum QuoteTreeNum { TREE_1 = 0, TREE_2 = 1, TREE_3 = 2 }; + +struct TTquotesTreeEntry { + uint _id; + TTquotesTreeEntry *_subTable; + CString _string; + + TTquotesTreeEntry() : _id(0), _subTable(nullptr) {} +}; + +class TTtreeResult { +public: + int _id; + const TTquotesTreeEntry *_treeItemP; +public: + TTtreeResult() : _id(0), _treeItemP(nullptr) {} +}; + +class TTquotesTree { +private: + TTquotesTreeEntry _entries[QUOTES_TREE_COUNT]; +private: + /** + * First inner search method + */ + bool search1(const char **str, const TTquotesTreeEntry *bTree, + TTtreeResult *buffer, uint tagId); + + /** + * Second inner search method + */ + bool search2(const char **str, const TTquotesTreeEntry *bTree, + TTtreeResult *buffer, uint tagId); + + /** + * Compare the current word in the string against a specified word + */ + bool compareWord(const char **str, const char *refStr); +public: + /** + * Load data for the quotes tree + */ + void load(); + + int search(const char *str, QuoteTreeNum treeNum, + TTtreeResult *buffer, uint tagId, uint *remainder); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_QUOTES_TREE_H */ diff --git a/engines/titanic/true_talk/tt_response.cpp b/engines/titanic/true_talk/tt_response.cpp new file mode 100644 index 0000000000..f007f98f97 --- /dev/null +++ b/engines/titanic/true_talk/tt_response.cpp @@ -0,0 +1,71 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_response.h" + +namespace Titanic { + +TTresponse::TTresponse(const TTstring &src) : _field0(0), _text(src), + _dialogueId(0), _nextP(nullptr), _linkP(nullptr) { +} + +TTresponse::TTresponse(int dialogueId, int val2) : _field0(val2), _text(" "), + _dialogueId(dialogueId), _nextP(nullptr), _linkP(nullptr) { +} + +TTresponse::TTresponse(const TTresponse *src) : _field0(src->_field0), + _text(src->_text), _dialogueId(src->_dialogueId), _nextP(src->_nextP), + _linkP(src->_linkP) { +} + +TTresponse::~TTresponse() { + // Iterate through destroying any successive linked response items + TTresponse *nextP; + for (TTresponse *currP = _nextP; currP; currP = nextP) { + // Get the following response and detach it from the current one, + // so that when the current is destroyed, it will only destroy itself + nextP = currP->_nextP; + currP->_nextP = nullptr; + delete currP; + } +} + +TTresponse *TTresponse::copyChain() const { + TTresponse *returnResponseP = new TTresponse(this); + + for (TTresponse *srcP = _nextP, *destP = returnResponseP; + srcP; srcP = srcP->_nextP, destP = destP->_nextP) { + destP->_nextP = new TTresponse(*srcP); + } + + return returnResponseP; +} + +void TTresponse::addLink(TTresponse *item) { + TTresponse *currP = this; + while (currP->_linkP) + currP = currP->_linkP; + + currP->_linkP = item; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_response.h b/engines/titanic/true_talk/tt_response.h new file mode 100644 index 0000000000..d39d18c193 --- /dev/null +++ b/engines/titanic/true_talk/tt_response.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_RESPONSE_H +#define TITANIC_TT_RESPONSE_H + +#include "titanic/true_talk/tt_string.h" +namespace Titanic { + +class TTsentence; + +class TTresponse { +private: + int _field0; + TTstring _text; + int _dialogueId; + TTresponse *_nextP; + TTresponse *_linkP; +public: + TTresponse(const TTstring &src); + TTresponse(int val1, int val2); + TTresponse(const TTresponse *src); + virtual ~TTresponse(); + + /** + * Makes a copy of the chain of responses + */ + TTresponse *copyChain() const; + + TTresponse *getLink() const { return _linkP; } + + void addLink(TTresponse *item); + + /** + * Get the dialogue Id for the response + */ + int getDialogueId() const { return _dialogueId; } + + /** + * Return the next response item, if present + */ + TTresponse *getNext() const { return _nextP; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_RESPONSE_H */ diff --git a/engines/titanic/true_talk/tt_room_script.cpp b/engines/titanic/true_talk/tt_room_script.cpp new file mode 100644 index 0000000000..b8fbca7d39 --- /dev/null +++ b/engines/titanic/true_talk/tt_room_script.cpp @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/tt_room_script.h" + +namespace Titanic { + +TTroomScriptBase::TTroomScriptBase(int scriptId, + const char *charClass, const char *charName, + int v3, int v4, int v5, int v6, int v2, int v7) : _scriptId(scriptId), + TTscriptBase(3, charClass, v2, charName, v3, v4, v5, v6, v7) { +} + +/*------------------------------------------------------------------------*/ + +TTroomScript::TTroomScript(int scriptId) : + TTroomScriptBase(scriptId, "", "", 0, -1, -1, -1, 0, 0) { +} + +bool TTroomScript::proc8() const { + return false; +} + +void TTroomScript::proc9(int v) { + if (v == 1) + _field54 = 1; +} + +ScriptChangedResult TTroomScript::scriptChanged(TTscriptBase *npcScript, int id) { + if (id == 1) + _field54 = 1; + + return SCR_1; +} + +bool TTroomScript::proc11() const { + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_room_script.h b/engines/titanic/true_talk/tt_room_script.h new file mode 100644 index 0000000000..39a50ac30d --- /dev/null +++ b/engines/titanic/true_talk/tt_room_script.h @@ -0,0 +1,103 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_ROOM_SCRIPT_H +#define TITANIC_TT_ROOM_SCRIPT_H + +#include "titanic/true_talk/tt_script_base.h" + +namespace Titanic { + +class TTnpcScript; +class TTsentence; + +class TTroomScriptBase : public TTscriptBase { +public: + uint _scriptId; +public: + TTroomScriptBase(int scriptId, const char *charClass, const char *charName, + int v3, int v4, int v5, int v6, int v2, int v7); + + /** + * Returns true if a response can be made + */ + virtual bool canRespond(TTnpcScript *npcScript, TTsentence *sentence, int val) const = 0; + + /** + * Returns true if further sentence processing is allowed + */ + virtual bool canProcess(TTnpcScript *npcScript, TTsentence *sentence) const = 0; + + virtual bool proc8() const = 0; + virtual void proc9(int v) = 0; + + /** + * Called when the script changes + */ + virtual ScriptChangedResult scriptChanged(TTscriptBase *npcScript, int id) = 0; + + virtual bool proc11() const = 0; +}; + + +class TTroomScript : public TTroomScriptBase { +public: + int _field54; +public: + TTroomScript(int scriptId); + + /** + * Returns true if a response can be made + */ + virtual bool canRespond(TTnpcScript *npcScript, TTsentence *sentence, int val) const { + return true; + } + + /** + * Returns true if further sentence processing is allowed + */ + virtual bool canProcess(TTnpcScript *npcScript, TTsentence *sentence) const { + return true; + } + + virtual bool proc8() const; + + virtual void proc9(int v); + + /** + * Called when the script changes + */ + virtual ScriptChangedResult scriptChanged(TTscriptBase *npcScript, int id); + + virtual bool proc11() const; + + /** + * Called with the new script and id + */ + ScriptChangedResult notifyScript(TTscriptBase *npcScript, int id) { + return scriptChanged(npcScript, id); + } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_ROOM_SCRIPT_H */ diff --git a/engines/titanic/true_talk/tt_script_base.cpp b/engines/titanic/true_talk/tt_script_base.cpp new file mode 100644 index 0000000000..4109134501 --- /dev/null +++ b/engines/titanic/true_talk/tt_script_base.cpp @@ -0,0 +1,156 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/tt_script_base.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTscriptBase::TTscriptBase(int scriptId, const char *charClass, int state, + const char *charName, int v3, int v4, int v5, int v6, int v7) : + _charName(charName), _charClass(charClass), _status(0), + _nodesP(nullptr), _id(0), _hist1P(nullptr), + _field20(0), _field24(0), _field28(0), _field2C(0), + _field30(0), _state(0), _hist2P(nullptr), _field3C(0), + _respHeadP(nullptr), _respTailP(nullptr), _oldResponseP(nullptr) { + if (!isValid()) { + if (!v7 || !getStatus()) { + _id = scriptId; + _field20 = v3; + _field24 = v4; + _field28 = v5; + _field2C = v6; + _field30 = v7; + _state = state; + } else { + _status = 5; + } + } + + if (_status) + reset(); +} + +TTscriptBase::~TTscriptBase() { + deleteResponses(); + delete _oldResponseP; + + delete _hist1P; + delete _hist2P; + + if (_nodesP) { + _nodesP->deleteSiblings(); + delete _nodesP; + } +} + +bool TTscriptBase::isValid() { + bool result = !_charName.isValid() && !_charClass.isValid(); + _status = result ? 0 : 11; + return result; +} + +void TTscriptBase::reset() { + _nodesP = nullptr; + _id = 4; + _hist1P = nullptr; + _field20 = 0; + _field24 = -1; + _field28 = -1; + _field2C = -1; + _field30 = 0; + _state = 0; + _hist2P = nullptr; + _field3C = 0; + _respHeadP = nullptr; + _respTailP = nullptr; + _oldResponseP = nullptr; +} + +int TTscriptBase::scriptPreprocess(TTsentence *sentence) { + delete _hist1P; + _hist1P = new TTscriptHist(sentence); + + return _hist1P ? SS_VALID : SS_7; +} + +void TTscriptBase::addResponse(const TTstring &str) { + appendResponse2(-1, nullptr, str); +} + +void TTscriptBase::addResponse(int id) { + appendResponse(-1, nullptr, id); +} + +void TTscriptBase::applyResponse() { + delete _oldResponseP; + _oldResponseP = nullptr; + + if (_respHeadP) { + g_vm->_scriptHandler->setResponse(this, _respHeadP); + _oldResponseP = _respHeadP->copyChain(); + TTresponse *oldRespP = _respHeadP; + _respHeadP = _respHeadP->getLink(); + _respTailP = nullptr; + + delete oldRespP; + } +} + +void TTscriptBase::deleteResponses() { + while (_respTailP) { + _respHeadP = _respTailP; + _respTailP = _respHeadP->getLink(); + delete _respHeadP; + } +} + +void TTscriptBase::appendResponse(int val1, int *val2, int val3) { + if (!val2 || val1 <= *val2) { + if (_respHeadP) { + _respHeadP = new TTresponse(_respHeadP); + } else { + _respHeadP = new TTresponse(val3, 3); + if (_respTailP) + _respTailP->addLink(_respHeadP); + else + _respTailP = _respHeadP; + } + } +} + +void TTscriptBase::appendResponse(int val1, int *val2, const TTstring &str) { + if (!val2 || val1 <= *val2) { + if (_respHeadP) { + _respHeadP = new TTresponse(str); + } else { + _respHeadP = new TTresponse(str); + if (_respTailP) + _respTailP->addLink(_respHeadP); + else + _respTailP = _respHeadP; + } + } +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_script_base.h b/engines/titanic/true_talk/tt_script_base.h new file mode 100644 index 0000000000..c489dcb0a7 --- /dev/null +++ b/engines/titanic/true_talk/tt_script_base.h @@ -0,0 +1,131 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_SCRIPT_BASE_H +#define TITANIC_TT_SCRIPT_BASE_H + +#include "titanic/true_talk/tt_string.h" +#include "titanic/true_talk/tt_hist.h" +#include "titanic/true_talk/tt_node.h" +#include "titanic/true_talk/tt_response.h" + +namespace Titanic { + +enum ScriptChangedResult { + SCR_0 = 0, SCR_1 = 1, SCR_2 = 2, SCR_3 = 3, SCR_4 = 4, SCR_5 = 5 +}; + +class TTsentence; + +class TTscriptBase { +private: + void reset(); +protected: + TTnode *_nodesP; + TThist *_hist1P; + TTstring _charName, _charClass; + int _field20; + int _field24; + int _field28; + int _field2C; + int _field30; + int _state; + TThist *_hist2P; + int _field3C; + TTresponse *_respHeadP; + TTresponse *_respTailP; + TTresponse *_oldResponseP; + int _status; +protected: + /** + * Delete any responses set up for the script + */ + void deleteResponses(); + + /** + * Creates and appends a new response to the script + */ + void appendResponse(int val1, int *val2, int val3); + + void appendResponse(int val1, int *val2, const TTstring &str); + + void appendResponse2(int val1, int *val2, const TTstring &str) { + appendResponse(val1, val2, str); + } + + /** + * Set the script state + */ + void setState(int state) { _state = state; } + + /** + * Get the current state + */ + int getState() const { return _state; } +public: + int _id; +public: + TTscriptBase(int scriptId, const char *charClass, int v2, const char *charName, + int v3, int v4, int v5, int v6, int v7); + virtual ~TTscriptBase(); + + virtual void addResponse(const TTstring &str); + + virtual void addResponse(int id); + + /** + * Passes on the list of dialogue Ids stored in the response(s) + * to the title engine for later display in the PET + */ + virtual void applyResponse(); + + /** + * Returns true if the script is in a valid state + */ + bool isValid(); + + /** + * Return the Id of the script + */ + int getId() const { return _id; } + + /** + * Return the status + */ + int getStatus() const { return _status; } + + /** + * Return the script text + */ + const TTstring getText() { return _charClass; } + + /** + * Gets passed a newly created input wrapper during conversation text processing + */ + int scriptPreprocess(TTsentence *sentence); + +}; + + +} // End of namespace Titanic + +#endif /* TITANIC_TT_SCRIPT_BASE_H */ diff --git a/engines/titanic/true_talk/tt_scripts.cpp b/engines/titanic/true_talk/tt_scripts.cpp new file mode 100644 index 0000000000..f8ea65a475 --- /dev/null +++ b/engines/titanic/true_talk/tt_scripts.cpp @@ -0,0 +1,97 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_scripts.h" +#include "titanic/true_talk/title_engine.h" +#include "titanic/true_talk/barbot_script.h" +#include "titanic/true_talk/bellbot_script.h" +#include "titanic/true_talk/deskbot_script.h" +#include "titanic/true_talk/doorbot_script.h" +#include "titanic/true_talk/liftbot_script.h" +#include "titanic/true_talk/maitred_script.h" +#include "titanic/true_talk/parrot_script.h" +#include "titanic/true_talk/succubus_script.h" + +namespace Titanic { + +TTnpcScript *TTnpcScriptList::findById(int charId) const { + for (TTnpcScriptList::const_iterator i = begin(); i != end(); ++i) { + const TTnpcScriptListItem *item = *i; + if (item->_npcScript->_charId == charId) + return item->_npcScript; + } + + return nullptr; +} + +/*------------------------------------------------------------------------*/ + +TTroomScript *TTroomScriptList::findById(uint scriptId) const { + for (TTroomScriptList::const_iterator i = begin(); i != end(); ++i) { + const TTroomScriptListItem *item = *i; + if (item->_item->_scriptId == scriptId) + return item->_item; + } + + return nullptr; +} + +/*------------------------------------------------------------------------*/ + +TTscripts::TTscripts(CTitleEngine *titleEngine) : + _titleEngine(titleEngine), _field24(0), _field28(0) { + // Load room scripts + for (int scriptNum = 100; scriptNum < 133; ++scriptNum) + addScript(new TTroomScript(scriptNum)); + + // Load npc scripts + addScript(new DoorbotScript(104, "Doorbot", 0, "Fentible", 11, 1, -1, -1, -1, 0), 100); + addScript(new BellbotScript(101, "Bellbot", 0, "Krage", 8, 1), 110); + addScript(new LiftbotScript(105, "LiftBot", 0, "Nobby", 11, 1, -1, -1, -1, 0), 103); + addScript(new DeskbotScript(103, "DeskBot", 0, "Marsinta", 11, 2), 110); + addScript(new BarbotScript(100, "Barbot", 0, "Fortillian", 9, 1, -1, -1, -1, 0), 112); + addScript(new ParrotScript(107, "Parrot", 0, "The Parrot", 5, 1, -1, -1, -1, 0), 111); + addScript(new MaitreDScript(112, "MaitreDBot", 0, "Dastrogaaar", 8, 1), 132); + addScript(new SuccUBusScript(111, "Succubus", 0, "Shorbert", 9, 1, -1, -1, -1, 0), 110); +} + +void TTscripts::addScript(TTnpcScript *script, int scriptId) { + // Find the room script this is associated with + TTroomScript *roomScript = getRoomScript(scriptId); + assert(roomScript); + + _npcScripts.push_back(new TTnpcScriptListItem(script, roomScript)); +} + +void TTscripts::addScript(TTroomScript *script) { + _roomScripts.push_back(new TTroomScriptListItem(script)); +} + +TTroomScript *TTscripts::getRoomScript(int scriptId) const { + return _roomScripts.findById(scriptId); +} + +TTnpcScript *TTscripts::getNpcScript(int charId) const { + return _npcScripts.findById(charId); +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_scripts.h b/engines/titanic/true_talk/tt_scripts.h new file mode 100644 index 0000000000..734d86256f --- /dev/null +++ b/engines/titanic/true_talk/tt_scripts.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_SCRIPTS_H +#define TITANIC_TT_SCRIPTS_H + +#include "titanic/core/list.h" +#include "titanic/true_talk/tt_npc_script.h" +#include "titanic/true_talk/tt_room_script.h" + +namespace Titanic { + +class CTitleEngine; + +class TTnpcScriptListItem : public ListItem { +public: + TTnpcScript *_npcScript; + TTroomScript *_roomScript; +public: + TTnpcScriptListItem() : _npcScript(nullptr), _roomScript(nullptr) {} + TTnpcScriptListItem(TTnpcScript *script, TTroomScript *roomScript) : + _npcScript(script), _roomScript(roomScript) {} + virtual ~TTnpcScriptListItem() { delete _npcScript; } +}; + +PTR_LIST_ITEM(TTroomScript); + +class TTnpcScriptList : public List<TTnpcScriptListItem> { +public: + TTnpcScript *findById(int charId) const; +}; + +class TTroomScriptList : public List<TTroomScriptListItem> { +public: + TTroomScript *findById(uint scriptId) const; +}; + +class TTscripts { +private: + TTnpcScriptList _npcScripts; + TTroomScriptList _roomScripts; + CTitleEngine *_titleEngine; + int _field24; + int _field28; +private: + /** + * Add a named script to the named scripts list + */ + void addScript(TTnpcScript *script, int charId); + + /** + * Add an unnamed script to the unnamed scripts list + */ + void addScript(TTroomScript *script); +public: + TTscripts(CTitleEngine *titleEngine); + + /** + * Return a pointer to the specified room script + */ + TTroomScript *getRoomScript(int scriptId) const; + + /** + * Return a pointer to the specified character script + */ + TTnpcScript *getNpcScript(int charId) const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_CHARACTERS_H */ diff --git a/engines/titanic/true_talk/tt_sentence.cpp b/engines/titanic/true_talk/tt_sentence.cpp new file mode 100644 index 0000000000..9588ee021e --- /dev/null +++ b/engines/titanic/true_talk/tt_sentence.cpp @@ -0,0 +1,347 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_sentence.h" +#include "titanic/true_talk/tt_concept.h" +#include "titanic/true_talk/script_handler.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTsentenceConcept *TTsentenceConcept::addSibling() { + if (this == nullptr || _nextP != nullptr) + // This should never happen + return nullptr; + + TTsentenceConcept *nextP = new TTsentenceConcept(); + _nextP = nextP; + return nextP; +} + +/*------------------------------------------------------------------------*/ + +TTsentence::TTsentence(int inputCtr, const TTstring &line, CScriptHandler *owner, + TTroomScript *roomScript, TTnpcScript *npcScript) : + _owner(owner), _field2C(1), _inputCtr(inputCtr), _field34(0), + _field38(0), _initialLine(line), _nodesP(nullptr), _roomScript(roomScript), + _npcScript(npcScript), _field58(0), _field5C(0) { + _status = _initialLine.isValid() && _normalizedLine.isValid() ? SS_11: SS_VALID; +} + +TTsentence::TTsentence(const TTsentence *src) : _sentenceConcept(src->_sentenceConcept), + _initialLine(src->_initialLine), _normalizedLine(src->_normalizedLine) { + copyFrom(*src); +} + +TTsentence::~TTsentence() { + _sentenceConcept.deleteSiblings(); + + if (_nodesP) { + _nodesP->deleteSiblings(); + delete _nodesP; + } +} + +void TTsentence::copyFrom(const TTsentence &src) { + if (!src.getStatus()) + _status = SS_5; + else if (!src._initialLine.isValid() || !src._normalizedLine.isValid()) + _status = SS_11; + else + _status = SS_VALID; + + _inputCtr = src._inputCtr; + _owner = src._owner; + _roomScript = src._roomScript; + _npcScript = src._npcScript; + _field58 = src._field58; + _field5C = src._field5C; + _field34 = src._field34; + _field38 = src._field38; + _field2C = src._field2C; + _nodesP = nullptr; + + if (src._nodesP) { + // Source has processed nodes, so duplicate them + for (TTsentenceNode *node = src._nodesP; node; + node = static_cast<TTsentenceNode *>(node->_nextP)) { + TTsentenceNode *newNode = new TTsentenceNode(node->_wordP); + if (_nodesP) + _nodesP->addToTail(newNode); + else + _nodesP = newNode; + } + } +} + +int TTsentence::storeVocabHit(TTword *word) { + if (!word) + return 0; + + TTsentenceNode *node = new TTsentenceNode(word); + if (_nodesP) { + _nodesP->addToTail(node); + } else { + _nodesP = node; + } + + return 0; +} + +bool TTsentence::fn1(const CString &str, int wordId1, const CString &str1, const CString &str2, + const CString &str3, int wordId2, int val1, int val2, const TTconceptNode *node) const { + if (node) + node = &_sentenceConcept; + + if (!node && !node) + return false; + if (val1 && !is18(val1, node)) + return false; + if (!str.empty() && !fn2(0, str, node)) + return false; + if (wordId1 && !fn4(1, wordId1, node)) + return false; + if (!str1.empty() && !fn2(2, str1, node)) + return false; + if (!str2.empty() && !fn2(3, str2, node)) + return false; + if (!str3.empty() && !fn2(4, str3, node)) + return false; + if (wordId2 && !fn4(5, wordId2, node)) + return false; + if (val2 && !is1C(val2, node)) + return false; + + return true; +} + +bool TTsentence::fn3(const CString &str1, const CString &str2, const CString &str3, + const CString &str4, const CString &str5, const CString &str6, + int val1, int val2, const TTconceptNode *node) const { + if (!node) + node = &_sentenceConcept; + + if (val1 && !is18(val1, node)) + return false; + if (!str1.empty() && !fn2(0, str1, node)) + return false; + if (!str2.empty() && !fn2(1, str2, node)) + return false; + if (!str3.empty() && !fn2(2, str3, node)) + return false; + if (!str4.empty() && !fn2(3, str4, node)) + return false; + if (!str5.empty() && !fn2(4, str5, node)) + return false; + if (!str6.empty() && !fn2(5, str6, node)) + return false; + if (!val2 && !is1C(val2, node)) + return false; + + return true; +} + +bool TTsentence::fn2(int slotIndex, const TTstring &str, const TTconceptNode *node) const { + if (!node) + node = &_sentenceConcept; + TTconcept *concept = getFrameSlot(slotIndex, node); + + if (!concept) + return str == "isEmpty"; + + bool abortFlag = false; + switch (concept->_scriptType) { + case 1: + if (str == "thePlayer") + abortFlag = 1; + break; + + case 2: + if (str == "targetNpc") + abortFlag = 1; + break; + + case 3: + if (str == "otherNpc") + abortFlag = 1; + break; + + default: + break; + } + + TTstring conceptText = concept->getText(); + if (abortFlag || str == conceptText || concept->compareTo(str)) { + delete concept; + return true; + } + + if (slotIndex == 1 && g_vm->_exeResources._owner->_concept4P) { + if (str == g_vm->_exeResources._owner->_concept4P->getText() && + conceptText == "do") + goto exit; + } + + if (g_vm->_exeResources._owner->_concept2P && (slotIndex == 0 || + slotIndex == 3 || slotIndex == 4)) { + if (str == g_vm->_exeResources._owner->_concept2P->getText() && + (conceptText == "it" || conceptText == "he" || conceptText == "she" || + conceptText == "him" || conceptText == "her" || conceptText == "them" || + conceptText == "they")) + goto exit; + } + + if (g_vm->_exeResources._owner->_concept1P && (slotIndex == 0 || + slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5)) { + if (str == g_vm->_exeResources._owner->_concept2P->getText() && + (conceptText == "it" || conceptText == "that" || conceptText == "he" || + conceptText == "she" || conceptText == "him" || conceptText == "her" || + conceptText == "them" || conceptText == "they" || conceptText == "those" || + conceptText == "1" || conceptText == "thing")) + goto exit; + } + + if (g_vm->_exeResources._owner->_concept1P && (slotIndex == 0 || slotIndex == 2)) { + if (conceptText == "?" && str == g_vm->_exeResources._owner->_concept2P->getText()) { + delete concept; + concept = getFrameSlot(5, node); + conceptText = concept->getText(); + + if (conceptText == "it" || conceptText == "that" || conceptText == "he" || + conceptText == "she" || conceptText == "him" || conceptText == "her" || + conceptText == "them" || conceptText == "they" || conceptText == "those" || + conceptText == "1" || conceptText == "thing") + abortFlag = true; + } + } + +exit: + delete concept; + return abortFlag; +} + +bool TTsentence::fn4(int mode, int wordId, const TTconceptNode *node) const { + if (!node) + node = &_sentenceConcept; + + switch (mode) { + case 1: + return node->_concept1P && node->_concept1P->getWordId() == wordId; + + case 5: + return node->_concept5P && node->_concept5P->getWordId() == wordId; + + default: + return false; + } +} + +TTconcept *TTsentence::getFrameEntry(int slotIndex, const TTconceptNode *conceptNode) const { + if (!conceptNode) + conceptNode = &_sentenceConcept; + + return conceptNode->_concepts[slotIndex]; +} + +TTconcept *TTsentence::getFrameSlot(int slotIndex, const TTconceptNode *conceptNode) const { + TTconcept *newConcept = new TTconcept(); + TTconcept *concept = getFrameEntry(slotIndex, conceptNode); + newConcept->copyFrom(concept); + + if (!newConcept->isValid()) { + delete newConcept; + newConcept = nullptr; + } + + return newConcept; +} + +bool TTsentence::isFrameSlotClass(int slotIndex, WordClass wordClass, const TTconceptNode *conceptNode) const { + TTconcept *concept = getFrameEntry(slotIndex, conceptNode); + if (concept && concept->_wordP) { + return concept->_wordP->isClass(wordClass); + } else { + return false; + } +} + +int TTsentence::is18(int val, const TTconceptNode *node) const { + if (!node) + node = &_sentenceConcept; + return node->_field18 == val; +} + +int TTsentence::is1C(int val, const TTconceptNode *node) const { + if (!node) + node = &_sentenceConcept; + return node->_field1C == val; +} + +bool TTsentence::isConcept34(int slotIndex, const TTconceptNode *node) const { + TTconcept *concept = getFrameEntry(slotIndex, node); + return concept && concept->getState(); +} + +bool TTsentence::localWord(const char *str) const { + CScriptHandler &scriptHandler = *g_vm->_exeResources._owner; + bool foundMatch = false; + + if (scriptHandler._concept1P) { + TTstring s = scriptHandler._concept1P->getText(); + if (s == str) + foundMatch = true; + } else if (scriptHandler._concept2P) { + TTstring s = scriptHandler._concept2P->getText(); + if (s == str) + foundMatch = true; + } + + int val = g_vm->_exeResources.get18(); + bool result = false; + + for (TTsentenceNode *nodeP = _nodesP; nodeP && !result; + nodeP = static_cast<TTsentenceNode *>(nodeP->_nextP)) { + TTsynonym syn; + if (!nodeP->_wordP) + continue; + + const TTstring wordStr = nodeP->_wordP->_text; + if (val == 3 && wordStr == str) { + result = true; + } else if (nodeP->_wordP->findSynByName(str, &syn, val)) { + result = true; + } else if (foundMatch) { + result = wordStr == "it" || wordStr == "that" || wordStr == "he" + || wordStr == "she" || wordStr == "him" || wordStr == "her" + || wordStr == "them" || wordStr == "they" || wordStr == "those" + || wordStr == "1" || wordStr == "thing"; + } + } + + return result; +} + +bool TTsentence::contains(const char *str) const { + return _initialLine.contains(str) || _normalizedLine.contains(str); +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_sentence.h b/engines/titanic/true_talk/tt_sentence.h new file mode 100644 index 0000000000..7b2c6400c5 --- /dev/null +++ b/engines/titanic/true_talk/tt_sentence.h @@ -0,0 +1,132 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_SENTENCE_H +#define TITANIC_TT_SENTENCE_H + +#include "common/array.h" +#include "titanic/true_talk/tt_concept_node.h" +#include "titanic/true_talk/tt_npc_script.h" +#include "titanic/true_talk/tt_room_script.h" +#include "titanic/true_talk/tt_sentence_node.h" +#include "titanic/true_talk/tt_string.h" + +namespace Titanic { + +class CScriptHandler; +class TTword; + +class TTsentenceConcept : public TTconceptNode { +public: + TTsentenceConcept() : TTconceptNode() {} + TTsentenceConcept(const TTsentenceConcept &src) : TTconceptNode(src) {} + + /** + * Adds a new sibling instance + */ + TTsentenceConcept *addSibling(); +}; + +class TTsentence { +private: + CScriptHandler *_owner; + int _inputCtr; + int _field34; + TTsentenceNode *_nodesP; + int _field5C; + int _status; +private: + /** + * Copy sentence data from a given source + */ + void copyFrom(const TTsentence &src); +public: + TTsentenceConcept _sentenceConcept; + TTstring _initialLine; + TTstring _normalizedLine; + int _field38; + int _field58; + TTroomScript *_roomScript; + TTnpcScript *_npcScript; + int _field2C; +public: + TTsentence(int inputCtr, const TTstring &line, CScriptHandler *owner, + TTroomScript *roomScript, TTnpcScript *npcScript); + TTsentence(const TTsentence *src); + ~TTsentence(); + + void setState(int v) { _field34 = v; } + void set38(int v) { _field38 = v; } + bool check2C() const { return _field2C > 1 && _field2C <= 10; } + int concept18(TTconceptNode *conceptNode) { + return conceptNode ? conceptNode->get18() : 0; + } + int get58() const { return _field58; } + int is18(int val, const TTconceptNode *node) const; + int is1C(int val, const TTconceptNode *node) const; + + int getStatus() const { return _status; } + + /** + * Gets a concept slot + */ + TTconcept *getFrameEntry(int slotIndex, const TTconceptNode *conceptNode = nullptr) const; + + /** + * Gets a conecpt slot and returns a duplicate of it + */ + TTconcept *getFrameSlot(int slotIndex, const TTconceptNode *conceptNode = nullptr) const; + + /** + * Returns true if the specified slot has an attached word with a given class + */ + bool isFrameSlotClass(int slotIndex, WordClass wordClass, const TTconceptNode *conceptNode = nullptr) const; + + /** + * Adds a found vocab word to the list of words representing + * the player's input + * @param word Word to node + */ + int storeVocabHit(TTword *word); + + bool fn1(const CString &str, int wordId1, const CString &str1, const CString &str2, + const CString &str3, int wordId2, int val1, int val2, const TTconceptNode *node) const; + bool fn3(const CString &str1, const CString &str2, const CString &str3, + const CString &str4, const CString &str5, const CString &str6, + int val1, int val2, const TTconceptNode *node) const; + bool fn2(int slotIndex, const TTstring &str, const TTconceptNode *node = nullptr) const; + bool fn4(int mode, int wordId, const TTconceptNode *node = nullptr) const; + + bool isConcept34(int slotIndex, const TTconceptNode *node = nullptr) const; + + bool localWord(const char *str) const; + + /** + * Returns true if the sentence (either the original or normalized lines) + * contain the specified substring + */ + bool contains(const char *str) const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_SENTENCE_H */ diff --git a/engines/titanic/true_talk/tt_sentence_node.cpp b/engines/titanic/true_talk/tt_sentence_node.cpp new file mode 100644 index 0000000000..33d7501c55 --- /dev/null +++ b/engines/titanic/true_talk/tt_sentence_node.cpp @@ -0,0 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/tt_sentence_node.h" + +namespace Titanic { + +TTsentenceNode::TTsentenceNode() : TTnode(), _wordP(nullptr) { +} + +TTsentenceNode::TTsentenceNode(TTword *word) : TTnode(), _wordP(word) { +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_sentence_node.h b/engines/titanic/true_talk/tt_sentence_node.h new file mode 100644 index 0000000000..18fa56fd57 --- /dev/null +++ b/engines/titanic/true_talk/tt_sentence_node.h @@ -0,0 +1,41 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_SENTENCE_NODE_H +#define TITANIC_TT_SENTENCE_NODE_H + +#include "titanic/true_talk/tt_node.h" +#include "titanic/true_talk/tt_word.h" + +namespace Titanic { + +class TTsentenceNode : public TTnode { +public: + TTword *_wordP; +public: + TTsentenceNode(); + TTsentenceNode(TTword *word); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_SENTENCE_NODE_H */ diff --git a/engines/titanic/true_talk/tt_string.cpp b/engines/titanic/true_talk/tt_string.cpp new file mode 100644 index 0000000000..198a8c2e80 --- /dev/null +++ b/engines/titanic/true_talk/tt_string.cpp @@ -0,0 +1,164 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_string.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +TTstring::TTstring() : _status(SS_VALID) { + _data = new TTstringData(); +} + +TTstring::TTstring(const char *str) : _status(SS_VALID) { + _data = new TTstringData(str); +} + +TTstring::TTstring(const CString &str) { + _status = SS_VALID; + _data = new TTstringData(str); +} + +TTstring::TTstring(const TTstring &str) { + if (str._status != SS_VALID) { + _status = SS_5; + _data = nullptr; + } else { + _status = SS_VALID; + _data = str._data; + _data->_referenceCount++; + } +} + +TTstring::~TTstring() { + if (_data && --_data->_referenceCount == 0) + delete _data; +} + +void TTstring::operator=(const TTstring &str) { + // Delete old string reference, if any + if (_data && --_data->_referenceCount == 0) + delete _data; + + // Copy source string data + _status = str._status; + _data = str._data; + if (_data) + _data->_referenceCount++; +} + +void TTstring::operator=(const CString &str) { + operator=(str.c_str()); +} + +void TTstring::operator=(const char *str) { + // Delete old string reference, if any + if (_data && --_data->_referenceCount == 0) + delete _data; + + // Create new string data + _data = new TTstringData(str); + _status = SS_VALID; +} + +TTstring &TTstring::operator+=(const char *str) { + _data->_string += str; + return *this; +} + +TTstring &TTstring::operator+=(const TTstring &str) { + _data->_string += str; + return *this; +} + +TTstring &TTstring::operator+=(char c) { + _data->_string += c; + return *this; +} + +bool TTstring::operator==(const TTstring &str) const { + return _data && str._data && _data->_string == str._data->_string; +} + +bool TTstring::operator==(const char *str) const { + return _data && _data->_string == str; +} + +void TTstring::save(SimpleFile *file) const { + file->writeFormat("%s", c_str()); +} + +TTstring TTstring::tokenize(const char *delim) { + const char *strP = _data->_string.c_str(); + const char *splitP = nullptr, *chP; + + for (const char *d = delim; d; ++d) { + chP = strchr(strP, *d); + if (chP && (splitP == nullptr || chP < splitP)) + splitP = chP; + } + + if (splitP) { + TTstring result(CString(strP, splitP)); + _data->_string = CString(splitP + 1); + return result; + } else { + return TTstring(); + } +} + +int TTstring::deletePrefix(int count) { + int strSize = size(); + if (count > strSize) + count = strSize; + + if (_data->_referenceCount == 1) { + // No other references to this string, so we can just directly modify it + _data->_string = CString(_data->_string.c_str() + count); + } else { + // Detach string from current shared data, and create a new one with the substring + _data->_referenceCount--; + _data = new TTstringData(_data->_string.c_str() + count); + } + + return 1; +} + +int TTstring::deleteSuffix(int count) { + int strSize = size(); + if (count > strSize) + count = strSize; + + CString newStr(_data->_string.c_str(), _data->_string.c_str() + strSize - count); + if (_data->_referenceCount == 1) { + // No other references to this string, so we can just directly modify it + _data->_string = newStr; + } else { + // Detach string from current shared data, and create a new one with the substring + _data->_referenceCount--; + _data = new TTstringData(newStr); + } + + return 1; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_string.h b/engines/titanic/true_talk/tt_string.h new file mode 100644 index 0000000000..5b12d93418 --- /dev/null +++ b/engines/titanic/true_talk/tt_string.h @@ -0,0 +1,173 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_STRING_H +#define TITANIC_TT_STRING_H + +#include "titanic/support/string.h" + +namespace Titanic { + +class SimpleFile; + +struct TTstringData { + CString _string; + int _referenceCount; + + TTstringData() : _referenceCount(1) {} + TTstringData(const char *str) : _string(str), _referenceCount(1) {} + TTstringData(const CString &str) : _string(str), _referenceCount(1) {} +}; + +enum TTstringStatus { + SS_VALID = 0, SS_1 = 1, SS_2 = 2, SS_3 = 3, SS_4 = 4, + SS_5 = 5, SS_7 = 7, SS_8 = 8, SS_11 = 11, SS_13 = 13 +}; + +class TTstring { +private: + TTstringData *_data; + TTstringStatus _status; +public: + TTstring(); + TTstring(const char *str); + TTstring(const CString &str); + TTstring(const TTstring &str); + virtual ~TTstring(); + + void operator=(const TTstring &str); + void operator=(const CString &str); + void operator=(const char *str); + TTstring &operator+=(const char *str); + TTstring &operator+=(const TTstring &str); + TTstring &operator+=(char c); + bool operator==(const TTstring &str) const; + bool operator==(const char *str) const; + + const char &operator[](int index) { + return *(c_str() + index); + } + + bool empty() const { + return _data->_string.empty(); + } + + char firstChar() const { + return _data->_string.firstChar(); + } + + char lastChar() const { + return _data->_string.lastChar(); + } + + int size() const { + return _data->_string.size(); + } + + void deleteLastChar() { + _data->_string.deleteLastChar(); + } + + bool hasPrefix(const CString &str) const { + return _data->_string.hasPrefix(str); + } + bool hasPrefix(const char *str) const { + return _data->_string.hasPrefix(str); + } + bool hasSuffix(const CString &str) const { + return _data->_string.hasSuffix(str); + } + bool hasSuffix(const char *str) const { + return _data->_string.hasSuffix(str); + } + + bool contains(const char *s) const { + return _data->_string.contains(s); + } + + /** + * Create a new copy of the string + */ + TTstring *copy() const { + return new TTstring(c_str()); + } + + /** + * Returns true if the string is valid + */ + bool isValid() const { + return _status == SS_VALID; + } + + /** + * Get the status of the string + */ + TTstringStatus getStatus() const { return _status; } + + /** + * Get a char * pointer to the string data + */ + const char *c_str() const { return _data->_string.c_str(); } + + /** + * Automatic operator to convert to a const char * + */ + operator const char *() const { return c_str(); } + + /** + * Get a character at a specified index + */ + char charAt(int index) const { return *(c_str() + index); } + + /** + * Save the sring to a passed file + */ + void save(SimpleFile *file) const; + + /** + * Compare a substring within the string at the specified index + */ + bool compareAt(int index, const char *str) const { + return !strncmp(c_str() + index, str, strlen(str)); + } + + /** + * Split off everything in the string until the first occurance + * of any specified delimiter character + */ + TTstring tokenize(const char *delim); + + /** + * Delets a specififed number of characters from the start of the string + */ + int deletePrefix(int count); + + /** + * Delets a specififed number of characters from the end of the string + */ + int deleteSuffix(int count); + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_STRING_H */ diff --git a/engines/titanic/true_talk/tt_string_node.cpp b/engines/titanic/true_talk/tt_string_node.cpp new file mode 100644 index 0000000000..2bb0c5a74b --- /dev/null +++ b/engines/titanic/true_talk/tt_string_node.cpp @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/textconsole.h" +#include "titanic/true_talk/tt_string_node.h" + +namespace Titanic { + +TTstringNode::TTstringNode() : TTnode() { +} + +void TTstringNode::initialize(int mode) { + _mode = mode; + _file = HANDLE_STDIN; + + if (_string.isValid()) { + _field1C = 0; + } else { + _field1C = 11; + warning("TTstringNode::initialize has bad subobj"); + } +} + +void TTstringNode::initialize(TTstringNode *oldNode) { + _mode = oldNode->_mode; + _file = oldNode->_file; + + if (_string.isValid()) { + _field1C = 0; + } else { + _field1C = 11; + warning("TTstringNode::initialize has bad subobj"); + } + + delete oldNode; +} + +TTstringNode *TTstringNode::findByName(const TTstring &str, int mode) { + for (TTstringNode *nodeP = this; nodeP; nodeP = static_cast<TTstringNode *>(nodeP->_nextP)) { + if (nodeP->_mode == mode || (mode == 3 && nodeP->_mode < 3)) { + if (nodeP->_string == str) + return nodeP; + } + } + + return nullptr; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_string_node.h b/engines/titanic/true_talk/tt_string_node.h new file mode 100644 index 0000000000..ced162b439 --- /dev/null +++ b/engines/titanic/true_talk/tt_string_node.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_STRING_NODE_H +#define TITANIC_TT_STRING_NODE_H + +#include "titanic/true_talk/tt_node.h" +#include "titanic/true_talk/tt_string.h" +#include "titanic/support/exe_resources.h" + +namespace Titanic { + +class TTstringNode : public TTnode { +protected: + /** + * Initializes state for the node + */ + void initialize(int mode); + + /** + * Initializes state for the node + */ + void initialize(TTstringNode *oldNode); +public: + TTstring _string; + FileHandle _file; + int _mode; + int _field1C; +public: + TTstringNode(); + + /** + * Find a string node in the linked chain by name + */ + TTstringNode *findByName(const TTstring &str, int mode); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_STRING_NODE_H */ diff --git a/engines/titanic/true_talk/tt_synonym.cpp b/engines/titanic/true_talk/tt_synonym.cpp new file mode 100644 index 0000000000..0f56c5cb22 --- /dev/null +++ b/engines/titanic/true_talk/tt_synonym.cpp @@ -0,0 +1,87 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_synonym.h" + +namespace Titanic { + +TTsynonym::TTsynonym() : TTstringNode(), _file(HANDLE_STDIN), + _mode(0), _field1C(0) { +} + +TTsynonym::TTsynonym(const TTsynonym *src) : TTstringNode(), + _mode(0), _field1C(0) { + _string = src->_string; + initialize(src->_mode); + _file = src->_file; +} + +TTsynonym::TTsynonym(int mode, const char *str, FileHandle file) : + TTstringNode(), _mode(0), _field1C(0) { + _string = str; + initialize(mode); + _file = file; +} + +TTsynonym::TTsynonym(int mode, TTstring *str) : TTstringNode() { + _string = *str; + initialize(mode); +} + +TTsynonym *TTsynonym::copyFrom(const TTsynonym *src) { + if (src->_field1C) { + _field1C = 5; + } else { + _field1C = 0; + if (src != this) + _string = src->_string; + } + + return this; +} + +int TTsynonym::save(SimpleFile *file) { + for (TTstringNode *synP = this; synP; synP = static_cast<TTstringNode *>(synP->_nextP)) { + file->writeFormat("%s", " 0 "); + synP->_string.save(file); + file->writeFormat("%c", ' '); + + if (synP->_mode) { + file->writeFormat("%1.0d", synP->_mode); + } else { + file->writeFormat("%c", '0'); + } + + file->writeFormat("%c", ' '); + + if (synP->_file) { + file->writeFormat("%2.0d", synP->_file); + } else { + file->writeFormat("%c", ' '); + } + file->writeFormat("%c", '\n'); + } + + return 0; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_synonym.h b/engines/titanic/true_talk/tt_synonym.h new file mode 100644 index 0000000000..d5dc2be09e --- /dev/null +++ b/engines/titanic/true_talk/tt_synonym.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_SYNONYM_H +#define TITANIC_TT_SYNONYM_H + +#include "titanic/true_talk/tt_string_node.h" +#include "titanic/support/simple_file.h" + +namespace Titanic { + +class TTsynonym : public TTstringNode { +public: + TTstring _string; + FileHandle _file; + int _mode; + int _field1C; +public: + TTsynonym(); + TTsynonym(const TTsynonym *src); + TTsynonym(int mode, const char *str, FileHandle file); + TTsynonym(int mode, TTstring *str); + + /** + * Copies data from one synonym to another + */ + TTsynonym *copyFrom(const TTsynonym *src); + + /** + * Save data for the synonym to file + */ + int save(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_SYNONYM_H */ diff --git a/engines/titanic/true_talk/tt_talker.cpp b/engines/titanic/true_talk/tt_talker.cpp new file mode 100644 index 0000000000..61443a4835 --- /dev/null +++ b/engines/titanic/true_talk/tt_talker.cpp @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_talker.h" +#include "titanic/messages/messages.h" +#include "titanic/pet_control/pet_control.h" + +namespace Titanic { + +void TTtalker::speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId) { + _dialogueId = dialogueId; + + CTrueTalkNotifySpeechStartedMsg msg(soundId, dialogueId, 0); + msg.execute(_npc, nullptr, MSGFLAG_BREAK_IF_HANDLED); +} + +TTtalker::~TTtalker() { + CPetControl *petControl = _npc->getPetControl(); + if (petControl) + // Add in final line + petControl->convAddLine(_line); + + // Notify the end of the speech + CTrueTalkNotifySpeechEndedMsg endedMsg(_field24, _dialogueId); + endedMsg.execute(_npc, nullptr, MSGFLAG_BREAK_IF_HANDLED); +} + +void TTtalker::endSpeech(int val) { + _done = true; + _field24 = val; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_talker.h b/engines/titanic/true_talk/tt_talker.h new file mode 100644 index 0000000000..636eb0c022 --- /dev/null +++ b/engines/titanic/true_talk/tt_talker.h @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_TALKER_H +#define TITANIC_TT_TALKER_H + +#include "titanic/core/list.h" +#include "titanic/npcs/true_talk_npc.h" +#include "titanic/support/string.h" + +namespace Titanic { + +class CTrueTalkManager; + +class TTtalker : public ListItem { +public: + CTrueTalkManager *_owner; + CTrueTalkNPC *_npc; + CString _line; + int _dialogueId; + int _field24; + int _done; +public: + TTtalker() : _owner(nullptr), _npc(nullptr), + _dialogueId(0), _field24(0), _done(0) {} + TTtalker(CTrueTalkManager *owner, CTrueTalkNPC *npc) : + _owner(owner), _npc(npc), _dialogueId(0), _field24(0), _done(0) {} + ~TTtalker(); + + /** + * Start a new speech + */ + void speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId); + + /** + * End the speech + */ + void endSpeech(int val); +}; + +class TTtalkerList : public List<TTtalker> { +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_TALKER_H */ diff --git a/engines/titanic/true_talk/tt_title_script.cpp b/engines/titanic/true_talk/tt_title_script.cpp new file mode 100644 index 0000000000..85b56d0e1e --- /dev/null +++ b/engines/titanic/true_talk/tt_title_script.cpp @@ -0,0 +1,31 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_title_script.h" + +namespace Titanic { + +TTTitleScript::TTTitleScript() : TTscriptBase(1, "", 0, "", 0, -1, -1, -1, 0), + _field50(0), _field5C(-1), _field60(0) { +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_title_script.h b/engines/titanic/true_talk/tt_title_script.h new file mode 100644 index 0000000000..f02e591c54 --- /dev/null +++ b/engines/titanic/true_talk/tt_title_script.h @@ -0,0 +1,43 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_TITLE_SCRIPT_H +#define TITANIC_TT_TITLE_SCRIPT_H + +#include "titanic/true_talk/tt_script_base.h" +#include "titanic/true_talk/tt_string.h" + +namespace Titanic { + +class TTTitleScript : public TTscriptBase { +private: + int _field50; + TTstring _string1; + int _field5C; + int _field60; +public: + TTTitleScript(); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_TITLE_SCRIPT_H */ diff --git a/engines/titanic/true_talk/tt_vocab.cpp b/engines/titanic/true_talk/tt_vocab.cpp new file mode 100644 index 0000000000..08d6e9e1a7 --- /dev/null +++ b/engines/titanic/true_talk/tt_vocab.cpp @@ -0,0 +1,557 @@ +/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/file.h"
+#include "titanic/true_talk/tt_vocab.h"
+#include "titanic/true_talk/tt_adj.h"
+#include "titanic/true_talk/tt_action.h"
+#include "titanic/true_talk/tt_adj.h"
+#include "titanic/true_talk/tt_major_word.h"
+#include "titanic/true_talk/tt_picture.h"
+#include "titanic/true_talk/tt_pronoun.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+TTvocab::TTvocab(int val): _headP(nullptr), _tailP(nullptr), _word(nullptr),
+ _fieldC(0), _field10(0), _vocabMode(val) {
+ load("STVOCAB.TXT");
+}
+
+TTvocab::~TTvocab() {
+ if (_headP) {
+ _headP->deleteSiblings();
+ delete _headP;
+ _headP = _tailP = nullptr;
+ }
+}
+
+int TTvocab::load(const CString &name) {
+ SimpleFile *file = g_vm->_exeResources._owner->openResource(name);
+ int result = 0;
+ bool skipFlag;
+
+ while (!result && !file->eos()) {
+ skipFlag = false;
+ WordClass wordClass = (WordClass)file->readNumber();
+ TTstring space(" ");
+
+ switch (wordClass) {
+ case WC_UNKNOWN: {
+ if (_word)
+ result = _word->readSyn(file);
+ skipFlag = true;
+ break;
+ }
+
+ case WC_ACTION: {
+ TTaction *word = new TTaction(space, WC_UNKNOWN, 0, 0, 0);
+ result = word->load(file);
+ _word = word;
+ break;
+ }
+
+ case WC_THING: {
+ TTpicture *word = new TTpicture(space, WC_UNKNOWN, 0, 0, 0, 0, 0);
+ result = word->load(file);
+ _word = word;
+ break;
+ }
+
+ case WC_ABSTRACT:
+ case WC_ADVERB: {
+ TTmajorWord *word = new TTmajorWord(space, WC_UNKNOWN, 0, 0);
+ result = word->load(file, wordClass);
+ _word = word;
+ break;
+ }
+
+ case WC_ARTICLE:
+ case WC_CONJUNCTION:
+ case WC_PREPOSITION: {
+ TTword *word = new TTword(space, WC_UNKNOWN, 0);
+ result = word->load(file, wordClass);
+ _word = word;
+ break;
+ }
+
+ case WC_ADJECTIVE: {
+ TTadj *word = new TTadj(space, WC_UNKNOWN, 0, 0, 0);
+ result = word->load(file);
+ _word = word;
+ break;
+ }
+
+ case WC_PRONOUN: {
+ TTpronoun *word = new TTpronoun(space, WC_UNKNOWN, 0, 0, 0);
+ result = word->load(file);
+ _word = word;
+ break;
+ }
+
+ default:
+ result = 4;
+ break;
+ }
+
+ if (!skipFlag && _word) {
+ if (result) {
+ // Something wrong occurred, so delete word
+ delete _word;
+ _word = nullptr;
+ } else {
+ // Add the word to the master vocab list
+ addWord(_word);
+ }
+ }
+ }
+
+ // Close resource and return result
+ delete file;
+ return result;
+}
+
+void TTvocab::addWord(TTword *word) {
+ TTword *existingWord = findWord(word->_text);
+
+ if (existingWord) {
+ if (word->_synP) {
+ // Move over the synonym
+ existingWord->appendNode(word->_synP);
+ word->_synP = nullptr;
+ }
+
+ _word = nullptr;
+ if (word)
+ delete word;
+ } else if (_tailP) {
+ _tailP->_nextP = word;
+ _tailP = word;
+ } else {
+ if (!_headP)
+ _headP = word;
+
+ _tailP = word;
+ }
+}
+
+TTword *TTvocab::findWord(const TTstring &str) {
+ TTsynonym *tempNode = new TTsynonym();
+ bool flag = false;
+ TTword *word = _headP;
+
+ while (word && !flag) {
+ if (_vocabMode != 3 || strcmp(word->c_str(), str)) {
+ if (word->findSynByName(str, tempNode, _vocabMode))
+ flag = true;
+ else
+ word = word->_nextP;
+ } else {
+ flag = true;
+ }
+ }
+
+ delete tempNode;
+ return word;
+}
+
+TTword *TTvocab::getWord(TTstring &str, TTword **srcWord) const {
+ TTword *word = getPrimeWord(str, srcWord);
+
+ if (!word) {
+ TTstring tempStr(str);
+ if (tempStr.size() > 2) {
+ word = getSuffixedWord(tempStr);
+
+ if (!word)
+ word = getPrefixedWord(tempStr);
+ }
+ }
+
+ return word;
+}
+
+TTword *TTvocab::getPrimeWord(TTstring &str, TTword **srcWord) const {
+ TTsynonym tempSyn;
+ char c = str.charAt(0);
+ TTword *newWord = nullptr;
+ TTword *vocabP;
+
+ if (!Common::isDigit(c)) {
+ vocabP = _headP;
+ newWord = new TTword(str, WC_ABSTRACT, 300);
+ } else {
+ for (vocabP = _headP; vocabP && !newWord; vocabP = vocabP->_nextP) {
+ if (_vocabMode == 3 && !strcmp(str.c_str(), vocabP->c_str())) {
+ newWord = vocabP->copy();
+ newWord->_nextP = nullptr;
+ newWord->setSyn(nullptr);
+ } else if (vocabP->findSynByName(str, &tempSyn, _vocabMode)) {
+ // Create a copy of the word and the found synonym
+ TTsynonym *newSyn = new TTsynonym(tempSyn);
+ newSyn->_nextP = newSyn->_priorP = nullptr;
+ newWord = vocabP->copy();
+ newWord->_nextP = nullptr;
+ newWord->setSyn(newSyn);
+ }
+ }
+ }
+
+ if (srcWord)
+ // Pass out the pointer to the original word
+ *srcWord = vocabP;
+
+ // Return the new copy of the word
+ return newWord;
+}
+
+TTword *TTvocab::getSuffixedWord(TTstring &str) const {
+ TTstring tempStr(str);
+ TTword *word = nullptr;
+
+ if (tempStr.hasSuffix("s")) {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (!word) {
+ if (!tempStr.hasSuffix("e")) {
+ tempStr = str;
+ } else {
+ tempStr.deleteLastChar();
+ word = getPrimeWord(tempStr);
+ }
+ }
+
+ } else if (tempStr.hasSuffix("ing")) {
+ tempStr.deleteSuffix(3);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass == 1) {
+ delete word;
+ word = nullptr;
+ } else {
+ delete word;
+ word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0);
+ }
+ } else {
+ tempStr += "e";
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass != 1) {
+ delete word;
+ word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0);
+ }
+ } else {
+ tempStr.deleteSuffix(2);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass != 1) {
+ delete word;
+ word = new TTadj(str, WC_ADJECTIVE, 0, 0, 0);
+ }
+ } else {
+ tempStr = str;
+ }
+ }
+ }
+
+ } else if (tempStr.hasSuffix("ed")) {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (!word) {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+ }
+
+ if (word) {
+ if (word->_wordClass == WC_ACTION) {
+ static_cast<TTaction *>(word)->setVal(1);
+ }
+ } else {
+ tempStr = str;
+ }
+
+ } else if (tempStr.hasSuffix("ly")) {
+ tempStr.deleteSuffix(2);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ delete word;
+ word = new TTword(str, WC_ADVERB, 0);
+ } else {
+ tempStr = str;
+ }
+
+ } else if (tempStr.hasSuffix("er")) {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass == WC_ADJECTIVE) {
+ TTadj *adj = static_cast<TTadj *>(word);
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0) {
+ adj->adjFn1(val1);
+ }
+ } else {
+ if (++val1 < 11) {
+ adj->adjFn1(val1);
+ }
+ }
+ }
+ } else {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass == WC_ADJECTIVE) {
+ TTadj *adj = static_cast<TTadj *>(word);
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0) {
+ adj->adjFn1(val1);
+ }
+ } else {
+ if (++val1 < 11) {
+ adj->adjFn1(val1);
+ }
+ }
+ }
+ } else {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (word && word->_wordClass == WC_ADJECTIVE) {
+ TTadj *adj = static_cast<TTadj *>(word);
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0) {
+ adj->adjFn1(val1);
+ }
+ } else {
+ if (++val1 < 11) {
+ adj->adjFn1(val1);
+ }
+ }
+ }
+ }
+ }
+
+ } else if (tempStr.hasSuffix("est")) {
+ tempStr.deleteSuffix(2);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass == WC_ADJECTIVE) {
+ TTadj *adj = static_cast<TTadj *>(word);
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0) {
+ adj->adjFn1(val1);
+ }
+ } else {
+ if (++val1 < 11) {
+ adj->adjFn1(val1);
+ }
+ }
+ }
+ } else {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass == WC_ADJECTIVE) {
+ TTadj *adj = static_cast<TTadj *>(word);
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0) {
+ adj->adjFn1(val1);
+ }
+ } else {
+ if (++val1 < 11) {
+ adj->adjFn1(val1);
+ }
+ }
+ }
+ } else {
+ tempStr.deleteSuffix(1);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ TTadj *adj = static_cast<TTadj *>(word);
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0) {
+ adj->adjFn1(val1);
+ }
+ } else {
+ if (++val1 < 11) {
+ adj->adjFn1(val1);
+ }
+ }
+ }
+ }
+ }
+
+ } else if (tempStr.hasSuffix("s*")) {
+ tempStr.deleteSuffix(2);
+ word = getPrimeWord(tempStr);
+
+ if (word) {
+ if (word->_wordClass == WC_PRONOUN || word->_wordClass == WC_ADVERB) {
+ delete word;
+ TTstring isStr("is");
+ word = getPrimeWord(isStr);
+ } else {
+ switch (word->_id) {
+ case 200:
+ if (word->proc10() == 2) {
+ delete word;
+ word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5);
+ } else if (word->proc10() == 1) {
+ delete word;
+ word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 4);
+ }
+ break;
+
+ case 201:
+ delete word;
+ word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5);
+ break;
+
+ case 202:
+ case 203:
+ if (word->proc10() == 2) {
+ delete word;
+ word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 5);
+ } else {
+ int val = word->proc10() == 1 ? 0 : 4;
+ delete word;
+ word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, val);
+ }
+ break;
+
+ case 204:
+ delete word;
+ word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 6);
+ break;
+
+ default:
+ delete word;
+ word = new TTpronoun(tempStr, WC_PRONOUN, 601, 0, 0);
+ break;
+ }
+ }
+ }
+ }
+
+ if (word)
+ word->setSynStr(str);
+
+ return word;
+}
+
+TTword *TTvocab::getPrefixedWord(TTstring &str) const {
+ TTstring tempStr(str);
+ TTword *word = nullptr;
+ int prefixLen = 0;
+
+ if (tempStr.hasPrefix("pre")) {
+ prefixLen = 3;
+ } else if (tempStr.hasPrefix("re") || tempStr.hasPrefix("co")) {
+ prefixLen = 2;
+ } else if (tempStr.hasPrefix("inter") || tempStr.hasPrefix("multi")) {
+ prefixLen = 5;
+ } else if (tempStr.hasPrefix("over") || tempStr.hasPrefix("post") || tempStr.hasPrefix("self")) {
+ prefixLen = 4;
+ }
+
+ if (prefixLen) {
+ // Known prefix found, so scan for word without prefix
+ tempStr.deletePrefix(prefixLen);
+ word = getPrimeWord(tempStr);
+ if (word)
+ tempStr = str;
+
+ } else if (tempStr.hasPrefix("anti") || tempStr.hasPrefix("counter")) {
+ prefixLen = tempStr[0] == 'a' ? 4 : 7;
+
+ tempStr.deletePrefix(prefixLen);
+ word = getPrimeWord(tempStr);
+ if (!word)
+ tempStr = str;
+ else if (word->_wordClass == 8) {
+ delete word;
+ word = nullptr;
+ }
+
+ } else if (tempStr.hasPrefix("hyper") || tempStr.hasPrefix("super") ||
+ tempStr.hasPrefix("ultra")) {
+ tempStr.deletePrefix(5);
+ word = getPrimeWord(tempStr);
+
+ if (!word)
+ tempStr = str;
+ else if (word->_wordClass == WC_ADJECTIVE) {
+ TTadj *adj = static_cast<TTadj *>(word);
+ int val1 = word->proc15();
+ int val2 = word->proc15();
+
+ if (val2 < 5) {
+ if (--val1 > 0)
+ adj->adjFn1(val1);
+ } else if (++val1 < 11) {
+ adj->adjFn1(val1);
+ }
+ }
+ }
+
+ if (word) {
+ // Set the original word on either the found word or synonym
+ if (word->hasSynonyms())
+ word->setSynStr(str);
+ else
+ word->_text = str;
+ }
+
+ delete tempStr;
+ return word;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/tt_vocab.h b/engines/titanic/true_talk/tt_vocab.h new file mode 100644 index 0000000000..fc7ee2e102 --- /dev/null +++ b/engines/titanic/true_talk/tt_vocab.h @@ -0,0 +1,96 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_ST_VOCAB_H +#define TITANIC_ST_VOCAB_H + +#include "titanic/support/string.h" +#include "titanic/true_talk/tt_string.h" +#include "titanic/true_talk/tt_word.h" + +namespace Titanic { + +class TTvocab { +private: + TTword *_headP; + TTword *_tailP; + TTword *_word; + int _fieldC; + int _field10; + int _vocabMode; +private: + /** + * Load the vocab data + */ + int load(const CString &name); + + /** + * Adds a specified word to the vocab list + */ + void addWord(TTword *word); + + /** + * Scans the vocab list for an existing word match + */ + TTword *findWord(const TTstring &str); + + /** + * Scans the vocab list for a word with a synonym matching the passed string. + * If found, creates a new word instance that only has the matching synonym + * linked to it. + * @param str Word text to scan for + * @param srcWord Optional pointer to store the original word match was found on + * @returns A new word instance if a match if found, or null if not + */ + TTword *getPrimeWord(TTstring &str, TTword **srcWord = nullptr) const; + + /** + * Checks the passed word for common suffixes, like 's', 'ing', etc. and, if found, + * checks for a word match for the base word without the suffix. + * @param str Word to check + * @returns New word instance for found match, or nullptr otherwise + */ + TTword *getSuffixedWord(TTstring &str) const; + + /** + * Checks the passed word for common prefixes, and checks for a word + * match for the word without the given prefix + * @param str Word to check + * @returns New word instance for found match, or nullptr otherwise + */ + TTword *getPrefixedWord(TTstring &str) const; +public: + TTvocab(int val); + ~TTvocab(); + + /** + * Gets a matching word from the vocab list given a passed string + * @param str Word text to scan for + * @param srcWord Optional pointer to store the original word match was found on + * @returns A new word instance if a match if found, or null if not + */ + TTword *getWord(TTstring &str, TTword **srcWord = nullptr) const; +}; + +} // End of namespace Titanic + +#endif /* TITANIC_ST_VOCAB_H */ diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp new file mode 100644 index 0000000000..df6ee5c7bc --- /dev/null +++ b/engines/titanic/true_talk/tt_word.cpp @@ -0,0 +1,226 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/true_talk/tt_word.h" +#include "titanic/true_talk/tt_string_node.h" +#include "titanic/titanic.h" + +namespace Titanic { + +TTword::TTword(const TTstring &str, WordClass wordClass, int id) : _text(str), + _wordClass(wordClass), _id(id), _tag(0), _field24(0), + _field28(0), _synP(nullptr), _nextP(nullptr) { + _status = str.getStatus() == SS_VALID ? SS_VALID : SS_5; +} + +TTword::TTword(const TTword *src) { + if (src->getStatus() != SS_VALID) { + _status = SS_5; + return; + } + + _text = src->_text; + _wordClass = src->_wordClass; + _id = src->_id; + _tag = src->_tag; + _synP = nullptr; + + TTsynonym *priorSyn = nullptr; + for (TTsynonym *synP = _synP; synP && !_status;) { + TTsynonym *newSyn = new TTsynonym(synP); + if (!newSyn) { + _status = SS_7; + } else { + newSyn->_priorP = priorSyn; + newSyn->_nextP = nullptr; + + if (priorSyn) { + priorSyn->_nextP = newSyn; + } else { + _synP = newSyn; + } + + priorSyn = newSyn; + } + } + + _nextP = src->_nextP; + _field24 = src->_field24; + _field28 = src->_field28; +} + +TTword::~TTword() { + if (_synP) { + _synP->deleteSiblings(); + delete _synP; + } +} + +void TTword::deleteSiblings() { + while (_nextP) { + TTword *next = _nextP; + _nextP = next->_nextP; + delete next; + } +} + +int TTword::readSyn(SimpleFile *file) { + CString str; + int mode, val1; + + if (!file->scanf("%s %d %d", &str, &mode, &val1)) + return 8; + if (!testFileHandle(file)) + return 5; + + // Create new synanym node + TTsynonym *synNode = new TTsynonym(mode, str.c_str(), (FileHandle)val1); + + if (_synP) { + // A synonym already exists, so add new one as a tail + // at the end of the linked list of synonyms + _synP->addToTail(synNode); + } else { + // Very first synonym, so set it + _synP = synNode; + } + + return 0; +} + +void TTword::setSyn(TTsynonym *synP) { + if (_synP) { + _synP->deleteSiblings(); + delete _synP; + } + + _synP = synP; +} + +int TTword::setSynStr(TTstring &str) { + if (str.empty()) + return 4; + + TTstring *newStr = new TTstring(str); + TTsynonym *newSyn = new TTsynonym(4, newStr); + setSyn(newSyn); + return 0; +} + +void TTword::appendNode(TTsynonym *node) { + if (_synP) + _synP->addToTail(node); + else + _synP = node; +} + +int TTword::load(SimpleFile *file, WordClass wordClass) { + CString str1, str2; + int id; + + if (file->scanf("%d %s %s", &id, &str1, &str2)) { + _text = str1; + _id = id; + _tag = readNumber(str2.c_str()); + _wordClass = wordClass; + return 0; + } else { + return 3; + } +} + +uint TTword::readNumber(const char *str) { + uint numValue = *str; + if (*str == '0') { + numValue = MKTAG('Z', 'Z', 'Z', '['); + } else { + ++str; + for (int idx = 0; idx < 3; ++idx, ++str) + numValue = (numValue << 8) + *str; + } + + return numValue; +} + +bool TTword::testFileHandle(FileHandle file) const { + if (g_vm->_exeResources.is18Equals(3)) + return true; + + // TODO: Figure out why original compares passed file handle against specific values + return true; +} + +bool TTword::findSynByName(const TTstring &str, TTsynonym *dest, int mode) const { + if (!_synP) + return false; + + const TTsynonym *synP = static_cast<const TTsynonym *>(_synP->findByName(str, mode)); + if (synP) { + dest->copyFrom(synP); + dest->_priorP = nullptr; + dest->_nextP = nullptr; + + return true; + } else { + return false; + } +} + +bool TTword::compareTo(const char *str) const { + return _text == str; +} + +TTword *TTword::copy() const { + return new TTword(this); +} + +FileHandle TTword::getSynFile() const { + return _synP ? _synP->_file : HANDLE_STDIN; +} + +bool TTword::checkSynFile(FileHandle file) const { + return _synP && _synP->_file == file; +} + +void TTword::setSynFile(FileHandle file) { + if (_synP && testFileHandle(file)) + _synP->_file = file; +} + +TTstringStatus TTword::getChainStatus() const { + for (const TTword *word = this; word; word = word->_nextP) { + if (word->getStatus()) + return word->getStatus(); + } + + return SS_VALID; +} + +TTword *TTword::copyWords() { + TTword *result = copy(); + for (TTword *word = result; word; word = word->_nextP) + word->_nextP = word->_nextP->copy(); + + return result; +} + +} // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h new file mode 100644 index 0000000000..7fd61c38ac --- /dev/null +++ b/engines/titanic/true_talk/tt_word.h @@ -0,0 +1,216 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_TT_WORD_H +#define TITANIC_TT_WORD_H + +#include "titanic/support/simple_file.h" +#include "titanic/true_talk/tt_string.h" +#include "titanic/true_talk/tt_synonym.h" + +namespace Titanic { + +/** + * Types of words + */ +enum WordClass { + WC_UNKNOWN = 0, WC_ACTION = 1, WC_THING = 2, WC_ABSTRACT = 3, + WC_ARTICLE = 4, WC_CONJUNCTION = 5, WC_PRONOUN = 6, + WC_PREPOSITION = 7, WC_ADJECTIVE = 8, WC_ADVERB = 9 +}; + +class TTword { +protected: + TTstringStatus _status; + int _field24; + int _field28; +protected: + /** + * Read in a number + */ + uint readNumber(const char *str); + + bool testFileHandle(SimpleFile *file) const { return true; } + bool testFileHandle(FileHandle resHandle) const; +public: + TTword *_nextP; + TTsynonym *_synP; + TTstring _text; + WordClass _wordClass; + int _id; + uint _tag; +public: + TTword(const TTstring &str, WordClass wordClass, int val2); + TTword(const TTword *src); + virtual ~TTword(); + + /** + * Delete any following words chained to the word + */ + void deleteSiblings(); + + /** + * Read in a synonym for the given word + */ + int readSyn(SimpleFile *file); + + /** + * Set a new synonym for the word + */ + void setSyn(TTsynonym *synP); + + /** + * Set a new synonym string + */ + int setSynStr(TTstring &str); + + /** + * Returns true if synonyms have been set for the word + */ + bool hasSynonyms() const { return _synP != nullptr; } + + /** + * Either sets the first synonym for a word, or adds it to an existing one + */ + void appendNode(TTsynonym *node); + + /** + * Load the word + */ + int load(SimpleFile *file, WordClass wordClass); + + /** + * Finds a synonym in the word by name, if one exists + * @param str Name to search for + * @param dest Destination synonym instance to copy match into + * @returns Returns true if a match was found + */ + bool findSynByName(const TTstring &str, TTsynonym *dest, int mode) const; + + const char *c_str() const { return _text.c_str(); } + operator const char *() const { return c_str(); } + + /** + * Return the text of the word + */ + const TTstring getText() { return _text; } + + /** + * Compares the word's text to a passed string + */ + bool compareTo(const char *str) const; + + /** + * Compares the word's text to a passed string + */ + bool compareTo(TTstring *str) const { + return compareTo(str->c_str()); + } + + /** + * Return the status of the word + */ + TTstringStatus getStatus() const { return _status; } + + /** + * Returns true if the word is in a valid state + */ + bool isValid() const { return _status == SS_VALID; } + + /** + * Return the status of the entire word chain + */ + TTstringStatus getChainStatus() const; + + /** + * Returns true if the word is of the specified class + */ + bool isClass(WordClass wordClass) const { return _wordClass == wordClass; } + + /** + * Copy the word and any attached to it + */ + TTword *copyWords(); + + /** + * Creates a copy of the word + */ + virtual TTword *copy() const; + + virtual bool proc2(int val) const { return false; } + virtual int proc3() const { return -1; } + virtual void proc4() {} + virtual void proc5() {} + + /** + * Checks whether the word's tag is a known type + */ + virtual bool checkTag() const { return false; } + + /** + * Compare the word's tag to a given tag value + */ + virtual bool compareTagTo(uint tag) const { return false; } + + /** + * Return the tag associated with the word + */ + virtual uint getTag() const { return 0; } + + virtual bool proc9(int val) const { return false; } + virtual int proc10() const { return 0; } + virtual void proc11() {} + virtual bool proc12(int val) const { return false; } + virtual int proc13() const { return 0; } + virtual bool proc14(int val) const { return false; } + virtual int proc15() const { return -1; } + virtual bool proc16() const { return false; } + virtual bool proc17() const { return false; } + virtual bool proc18() const { return false; } + virtual bool comparePronounTo(int val) const { return false; } + virtual int proc20() const { return 0; } + + /** + * Returns the file associated with the word's first synonym + */ + virtual FileHandle getSynFile() const; + + /** + * Checks whether the file associated with the word's first + * synonym matches the specified file + */ + virtual bool checkSynFile(FileHandle file) const; + + /** + * Sets the file associated with a synonym + */ + virtual void setSynFile(FileHandle file); + + /** + * Dumps data associated with the word to file + */ + virtual int save(SimpleFile *file) const { return 0; } +}; + +} // End of namespace Titanic + +#endif /* TITANIC_TT_WORD_H */ |