diff options
-rw-r--r-- | engines/titanic/input_handler.cpp | 18 | ||||
-rw-r--r-- | engines/titanic/input_handler.h | 8 | ||||
-rw-r--r-- | engines/titanic/input_translator.cpp | 12 |
3 files changed, 24 insertions, 14 deletions
diff --git a/engines/titanic/input_handler.cpp b/engines/titanic/input_handler.cpp index 15aac18cca..8bd8bba9a9 100644 --- a/engines/titanic/input_handler.cpp +++ b/engines/titanic/input_handler.cpp @@ -63,20 +63,22 @@ void CInputHandler::decLockCount() { } } -void CInputHandler::handleMessage(CMessage &msg, bool respectLock) { +bool CInputHandler::handleMessage(CMessage &msg, bool respectLock) { if (!respectLock || _lockCount <= 0) { if (_gameManager->_gameState._mode == GSMODE_INTERACTIVE) { - processMessage(&msg); + return processMessage(&msg); } else if (!msg.isMouseMsg()) { g_vm->_filesManager->loadDrive(); } } + + return false; } -void CInputHandler::processMessage(CMessage *msg) { +bool CInputHandler::processMessage(CMessage *msg) { const CMouseMsg *mouseMsg = dynamic_cast<const CMouseMsg *>(msg); _abortMessage = false; - dispatchMessage(msg); + bool handled = dispatchMessage(msg); if (_abortMessage) { _abortMessage = false; @@ -140,14 +142,18 @@ void CInputHandler::processMessage(CMessage *msg) { } } } + + return handled; } -void CInputHandler::dispatchMessage(CMessage *msg) { +bool 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); + return msg->execute(view); } + + return true; } CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) { diff --git a/engines/titanic/input_handler.h b/engines/titanic/input_handler.h index 69434cda88..3fd93a2ac8 100644 --- a/engines/titanic/input_handler.h +++ b/engines/titanic/input_handler.h @@ -35,13 +35,15 @@ class CInputHandler { private: /** * Process and dispatch a passed message + * @returns True if message was handled */ - void processMessage(CMessage *msg); + bool processMessage(CMessage *msg); /** * Dispatches a message to the project + * @returns True if message was handled */ - void dispatchMessage(CMessage *msg); + bool dispatchMessage(CMessage *msg); /** * Called when a drag operation has ended @@ -76,7 +78,7 @@ public: /** * Handles a genereated mouse message */ - void handleMessage(CMessage &msg, bool respectLock = true); + bool handleMessage(CMessage &msg, bool respectLock = true); /** * Returns true if input is locked diff --git a/engines/titanic/input_translator.cpp b/engines/titanic/input_translator.cpp index bd805258d5..c5640a48bc 100644 --- a/engines/titanic/input_translator.cpp +++ b/engines/titanic/input_translator.cpp @@ -86,13 +86,15 @@ void CInputTranslator::mouseWheel(bool wheelUp, const Point &pt) { } void CInputTranslator::keyDown(const Common::KeyState &keyState) { - if (isSpecialKey(keyState.keycode)) { - CVirtualKeyCharMsg msg(keyState); - _inputHandler->handleMessage(msg); - } - if (keyState.ascii > 0 && keyState.ascii <= 127) { CKeyCharMsg msg(keyState.ascii); + if (_inputHandler->handleMessage(msg)) + return; + } + + if (isSpecialKey(keyState.keycode)) { + CVirtualKeyCharMsg msg(keyState); + msg._keyState.ascii = 0; _inputHandler->handleMessage(msg); } } |