diff options
author | Paul Gilbert | 2016-05-28 19:52:48 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:16:40 -0400 |
commit | a7ecc6d601f1beabd0f5538d5e1cd7d6e983d2b9 (patch) | |
tree | 28069093089951057a2b0ae3db7578711cf3ff53 | |
parent | 1f4eca3d061d85cdc11a8e20834c14de082baedc (diff) | |
download | scummvm-rg350-a7ecc6d601f1beabd0f5538d5e1cd7d6e983d2b9.tar.gz scummvm-rg350-a7ecc6d601f1beabd0f5538d5e1cd7d6e983d2b9.tar.bz2 scummvm-rg350-a7ecc6d601f1beabd0f5538d5e1cd7d6e983d2b9.zip |
TITANIC: Adding CDeskbot message handlers
-rw-r--r-- | engines/titanic/carry/magazine.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/core/game_object.cpp | 28 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 17 | ||||
-rw-r--r-- | engines/titanic/npcs/deskbot.cpp | 90 | ||||
-rw-r--r-- | engines/titanic/npcs/deskbot.h | 4 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.h | 10 |
7 files changed, 138 insertions, 15 deletions
diff --git a/engines/titanic/carry/magazine.cpp b/engines/titanic/carry/magazine.cpp index ac74da8c71..68d898c399 100644 --- a/engines/titanic/carry/magazine.cpp +++ b/engines/titanic/carry/magazine.cpp @@ -54,7 +54,7 @@ void CMagazine::load(SimpleFile *file) { bool CMagazine::UseWithCharMsg(CUseWithCharMsg *msg) { CDeskbot *deskbot = static_cast<CDeskbot *>(msg->_character); if (deskbot) { - if (deskbot->_field108) { + if (deskbot->_deskbotActive) { setVisible(false); setPosition(Point(1000, 1000)); CActMsg actMsg("2ndClassUpgrade"); diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 5a214871c6..f386c1eb51 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -707,6 +707,30 @@ void CGameObject::incState38() { getGameManager()->_gameState.inc38(); } +void CGameObject::inc54() { + getGameManager()->inc54(); +} + +void CGameObject::dec54() { + getGameManager()->dec54(); +} + +void CGameObject::lockMouse() { + CGameManager *gameMan = getGameManager(); + gameMan->lockInputHandler(); + + if (CScreenManager::_screenManagerPtr->_mouseCursor) + CScreenManager::_screenManagerPtr->_mouseCursor->hide(); +} + +void CGameObject::unlockMouse() { + if (CScreenManager::_screenManagerPtr->_mouseCursor) + CScreenManager::_screenManagerPtr->_mouseCursor->show(); + + CGameManager *gameMan = getGameManager(); + gameMan->unlockInputHandler(); +} + void CGameObject::startTalking(const CString &npcName, uint id, CViewItem *view) { CTrueTalkNPC *npc = static_cast<CTrueTalkNPC *>(getRoot()->findByName(npcName)); startTalking(npc, id, view); @@ -721,6 +745,10 @@ void CGameObject::startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) { } } +void CGameObject::endTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) { + warning("TODO: CGameObject::endTalking"); +} + void CGameObject::loadSurface() { if (!_surface && !_resource.empty()) { loadResource(_resource); diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 87cc2baa7e..10847c816c 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -126,6 +126,18 @@ protected: void petFn2(int val); void petFn3(CTreeItem *item); void incState38(); + void inc54(); + void dec54(); + + /** + * Locks/hides the mouse + */ + void lockMouse(); + + /** + * Unlocks/shows the mouse + */ + void unlockMouse(); /** * Load a sound @@ -228,6 +240,11 @@ protected: void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr); /** + * Stop a conversation with the NPC + */ + void endTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr); + + /** * Load the surface */ void loadSurface(); diff --git a/engines/titanic/npcs/deskbot.cpp b/engines/titanic/npcs/deskbot.cpp index e0e147fabf..dcd27466db 100644 --- a/engines/titanic/npcs/deskbot.cpp +++ b/engines/titanic/npcs/deskbot.cpp @@ -41,14 +41,14 @@ END_MESSAGE_MAP() int CDeskbot::_v1; int CDeskbot::_v2; -CDeskbot::CDeskbot() : CTrueTalkNPC(), _field108(0), _field10C(0) { +CDeskbot::CDeskbot() : CTrueTalkNPC(), _deskbotActive(false), _field10C(0) { } void CDeskbot::save(SimpleFile *file, int indent) const { file->writeNumberLine(1, indent); file->writeNumberLine(_v1, indent); file->writeNumberLine(_v2, indent); - file->writeNumberLine(_field108, indent); + file->writeNumberLine(_deskbotActive, indent); file->writeNumberLine(_field10C, indent); CTrueTalkNPC::save(file, indent); @@ -58,34 +58,99 @@ void CDeskbot::load(SimpleFile *file) { file->readNumber(); _v1 = file->readNumber(); _v2 = file->readNumber(); - _field108 = file->readNumber(); + _deskbotActive = file->readNumber(); _field10C = file->readNumber(); CTrueTalkNPC::load(file); } bool CDeskbot::TurnOn(CTurnOn *msg) { - // TODO + if (!_deskbotActive) { + setVisible(true); + playClip("BellRinging", 4); + playSound("b#69.wav"); + setPetArea(PET_CONVERSATION); + + _npcFlags |= NPCFLAG_20000; + _deskbotActive = true; + } + return true; } bool CDeskbot::EnterViewMsg(CEnterViewMsg *msg) { - // TODO + setVisible(false); + _deskbotActive = false; + _fieldC4 = 0; + loadFrame(625); + return true; } bool CDeskbot::ActMsg(CActMsg *msg) { - // TODO + if (msg->_action == "2ndClassUpgrade" && getPassengerClass() > 2) { + startTalking(this, 140, findView()); + } + return true; } bool CDeskbot::MovieEndMsg(CMovieEndMsg *msg) { - // TODO + bool flag = false; + if (_npcFlags & NPCFLAG_10000) { + if (_field10C) { + setPetArea(PET_ROOMS); + dec54(); + unlockMouse(); + playSound("z#47.wav", 100, 0, 0); + _field10C = false; + } + + _npcFlags &= ~NPCFLAG_10000; + flag = true; + } + + bool flag = false; + 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) { - // TODO + if (_deskbotActive) { + CTurnOff turnOff; + turnOff.execute(this); + } + return true; } @@ -115,7 +180,14 @@ bool CDeskbot::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) } bool CDeskbot::TurnOff(CTurnOff *msg) { - // TODO + if (_deskbotActive) { + stopMovie(); + performAction(1, findView()); + + _npcFlags = (_npcFlags & ~(NPCFLAG_SPEAKING | NPCFLAG_2 | NPCFLAG_4)) | NPCFLAG_40000; + playClip("Closing", 0x14); + } + return true; } diff --git a/engines/titanic/npcs/deskbot.h b/engines/titanic/npcs/deskbot.h index 2711e9cc43..607255be57 100644 --- a/engines/titanic/npcs/deskbot.h +++ b/engines/titanic/npcs/deskbot.h @@ -44,8 +44,8 @@ private: static int _v1; static int _v2; public: - int _field108; - int _field10C; + bool _deskbotActive; + bool _field10C; public: CLASSDEF CDeskbot(); diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp index 297de59178..ba2de20de9 100644 --- a/engines/titanic/npcs/true_talk_npc.cpp +++ b/engines/titanic/npcs/true_talk_npc.cpp @@ -197,7 +197,7 @@ void CTrueTalkNPC::processInput(CTextInputMsg *msg, CViewItem *view) { talkManager->processInput(this, msg, view); } -void CTrueTalkNPC::performAction(int val1, int val2) { +void CTrueTalkNPC::performAction(int actionNum, CViewItem *view) { // TODO } diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h index 8277b55e45..a1303c3e5d 100644 --- a/engines/titanic/npcs/true_talk_npc.h +++ b/engines/titanic/npcs/true_talk_npc.h @@ -30,7 +30,9 @@ namespace Titanic { enum NpcFlag { - NPCFLAG_SPEAKING = 1, NPCFLAG_2 = 2, NPCFLAG_4 = 4, NPCFLAG_8 = 8 + 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; @@ -60,7 +62,11 @@ protected: int _field104; protected: void processInput(CTextInputMsg *msg, CViewItem *view); - void performAction(int val1, int val2); + + /** + * Perform an action + */ + void performAction(int actionNum, CViewItem *view = nullptr); /** * Start an animation timer |