diff options
Diffstat (limited to 'engines/titanic/game')
-rw-r--r-- | engines/titanic/game/code_wheel.cpp | 66 | ||||
-rw-r--r-- | engines/titanic/game/code_wheel.h | 7 | ||||
-rw-r--r-- | engines/titanic/game/no_nut_bowl.cpp | 21 | ||||
-rw-r--r-- | engines/titanic/game/no_nut_bowl.h | 4 | ||||
-rw-r--r-- | engines/titanic/game/nose_holder.cpp | 79 | ||||
-rw-r--r-- | engines/titanic/game/nose_holder.h | 8 | ||||
-rw-r--r-- | engines/titanic/game/nut_replacer.cpp | 16 | ||||
-rw-r--r-- | engines/titanic/game/nut_replacer.h | 3 |
8 files changed, 198 insertions, 6 deletions
diff --git a/engines/titanic/game/code_wheel.cpp b/engines/titanic/game/code_wheel.cpp index d8ce48e390..94ee25435a 100644 --- a/engines/titanic/game/code_wheel.cpp +++ b/engines/titanic/game/code_wheel.cpp @@ -24,13 +24,20 @@ namespace Titanic { -CodeWheel::CodeWheel() : CBomb(), _field108(0), _field10C(4), _field110(0) { +BEGIN_MESSAGE_MAP(CodeWheel, CBomb) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + +CodeWheel::CodeWheel() : CBomb(), _field108(0), _state(4), _field110(0) { } void CodeWheel::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_field108, indent); - file->writeNumberLine(_field10C, indent); + file->writeNumberLine(_state, indent); file->writeNumberLine(_field110, indent); CBomb::save(file, indent); @@ -39,10 +46,63 @@ void CodeWheel::save(SimpleFile *file, int indent) { void CodeWheel::load(SimpleFile *file) { file->readNumber(); _field108 = file->readNumber(); - _field10C = file->readNumber(); + _state = file->readNumber(); _field110 = file->readNumber(); CBomb::load(file); } +bool CodeWheel::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + static const int START_FRAMES[15] = { + 0, 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66 + }; + static const int END_FRAMES[15] = { + 5, 10, 15, 19, 24, 28, 33, 38, 42, 47, 52, 57, 61, 66, 70 + }; + + int yp = _bounds.top + _bounds.height() / 2; + if (msg->_mousePos.y > yp) { + if (_state == _field108) + _field110 = true; + + _state = (_state + 1) % 15; + playMovie(START_FRAMES[_state], END_FRAMES[_state], + MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + } else { + if (_state == _field108) + _field110 = true; + + playMovie(START_FRAMES[14 - _state] + 68, END_FRAMES[14 - _state] + 68, + MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + + _state = (_state <= 0) ? 14 : _state - 1; + } + + playSound("z#59.wav"); + return true; +} + +bool CodeWheel::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(24); + _state = 4; + return true; +} + +bool CodeWheel::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + return true; +} + +bool CodeWheel::MovieEndMsg(CMovieEndMsg *msg) { + sleep(200); + CStatusChangeMsg changeMsg; + changeMsg._newStatus = 0; + if (_field110) + changeMsg._newStatus = -1; + if (_field108 == _state) + changeMsg._newStatus = 1; + changeMsg.execute("Bomb"); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/code_wheel.h b/engines/titanic/game/code_wheel.h index 63af97c6fb..e38a45b631 100644 --- a/engines/titanic/game/code_wheel.h +++ b/engines/titanic/game/code_wheel.h @@ -28,9 +28,14 @@ namespace Titanic { class CodeWheel : public CBomb { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); private: int _field108; - int _field10C; + int _state; int _field110; public: CLASSDEF; diff --git a/engines/titanic/game/no_nut_bowl.cpp b/engines/titanic/game/no_nut_bowl.cpp index 47f9d7901e..8c0a95ac9a 100644 --- a/engines/titanic/game/no_nut_bowl.cpp +++ b/engines/titanic/game/no_nut_bowl.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CNoNutBowl, CBackground) + ON_MESSAGE(ActMsg) + ON_MESSAGE(ReplaceBowlAndNutsMsg) + ON_MESSAGE(NutPuzzleMsg) +END_MESSAGE_MAP() + void CNoNutBowl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +40,19 @@ void CNoNutBowl::load(SimpleFile *file) { CBackground::load(file); } +bool CNoNutBowl::ActMsg(CActMsg *msg) { + return true; +} + +bool CNoNutBowl::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { + setVisible(false); + return true; +} + +bool CNoNutBowl::NutPuzzleMsg(CNutPuzzleMsg *msg) { + if (msg->_value == "NutsGone") + setVisible(true); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/no_nut_bowl.h b/engines/titanic/game/no_nut_bowl.h index 548b324869..cd8bc65179 100644 --- a/engines/titanic/game/no_nut_bowl.h +++ b/engines/titanic/game/no_nut_bowl.h @@ -28,6 +28,10 @@ namespace Titanic { class CNoNutBowl : public CBackground { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg); + bool NutPuzzleMsg(CNutPuzzleMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/nose_holder.cpp b/engines/titanic/game/nose_holder.cpp index cd9433ee9c..ac6c10dafd 100644 --- a/engines/titanic/game/nose_holder.cpp +++ b/engines/titanic/game/nose_holder.cpp @@ -24,7 +24,16 @@ namespace Titanic { -CNoseHolder::CNoseHolder() : CDropTarget(), _field118(0), _field11C(0) { +BEGIN_MESSAGE_MAP(CNoseHolder, CDropTarget) + ON_MESSAGE(ActMsg) + ON_MESSAGE(FrameMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CNoseHolder::CNoseHolder() : CDropTarget(), _dragObject(nullptr), + _field11C(0) { } void CNoseHolder::save(SimpleFile *file, int indent) { @@ -41,4 +50,72 @@ void CNoseHolder::load(SimpleFile *file) { CDropTarget::load(file); } +bool CNoseHolder::ActMsg(CActMsg *msg) { + if (msg->_action == "Sneeze" && !_itemName.empty() && _fieldF4) { + CProximity prox; + prox._positioningMode = POSMODE_VECTOR; + playSound("z#35.wav", prox); + + if (getView() == findView()) { + setVisible(true); + playMovie(1, 13, MOVIE_NOTIFY_OBJECT); + } + } + + return true; +} + +bool CNoseHolder::FrameMsg(CFrameMsg *msg) { + if (!_dragObject) { + CGameObject *dragObj = getDraggingObject(); + if (!dragObj) + return false; + + if (!dragObj->isEquals("Feathers") || getView() != findView()) + return false; + + _dragObject = dragObj; + } + + if (_dragObject) { + if (!checkPoint(Point(_dragObject->_bounds.left, + _dragObject->_bounds.top))) { + _field11C = false; + } else if (!_field11C) { + CActMsg actMsg("Sneeze"); + actMsg.execute(this); + _field11C = true; + } + } + + return true; +} + +bool CNoseHolder::LeaveViewMsg(CLeaveViewMsg *msg) { + _field11C = false; + _dragObject = nullptr; + if (_fieldF4) { + loadFrame(_dropFrame); + setVisible(false); + } + + return true; +} + +bool CNoseHolder::MovieEndMsg(CMovieEndMsg *msg) { + if (_fieldF4) { + loadFrame(_dropFrame); + setVisible(false); + } + + return true; +} + +bool CNoseHolder::EnterViewMsg(CEnterViewMsg *msg) { + if (_fieldF4) + setVisible(false); + + return CDropTarget::EnterViewMsg(msg); +} + } // End of namespace Titanic diff --git a/engines/titanic/game/nose_holder.h b/engines/titanic/game/nose_holder.h index b8cca95869..7b3fbba625 100644 --- a/engines/titanic/game/nose_holder.h +++ b/engines/titanic/game/nose_holder.h @@ -28,8 +28,14 @@ namespace Titanic { class CNoseHolder : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool FrameMsg(CFrameMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); private: - int _field118; + CGameObject *_dragObject; int _field11C; public: CLASSDEF; diff --git a/engines/titanic/game/nut_replacer.cpp b/engines/titanic/game/nut_replacer.cpp index 9a73355c91..6b05d1d0e9 100644 --- a/engines/titanic/game/nut_replacer.cpp +++ b/engines/titanic/game/nut_replacer.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CNutReplacer, CGameObject) + ON_MESSAGE(ReplaceBowlAndNutsMsg) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CNutReplacer::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +39,15 @@ void CNutReplacer::load(SimpleFile *file) { CGameObject::load(file); } +bool CNutReplacer::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { + setVisible(true); + playMovie(MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + return true; +} + +bool CNutReplacer::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/nut_replacer.h b/engines/titanic/game/nut_replacer.h index ead9713801..e2eed4e247 100644 --- a/engines/titanic/game/nut_replacer.h +++ b/engines/titanic/game/nut_replacer.h @@ -28,6 +28,9 @@ namespace Titanic { class CNutReplacer : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; |