TITANIC: Fix handling of NumPad causing double digits

This commit is contained in:
Paul Gilbert 2017-08-06 11:23:12 -04:00
parent 665f5c99b2
commit 17089becd4
3 changed files with 24 additions and 14 deletions

View File

@ -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 (!respectLock || _lockCount <= 0) {
if (_gameManager->_gameState._mode == GSMODE_INTERACTIVE) { if (_gameManager->_gameState._mode == GSMODE_INTERACTIVE) {
processMessage(&msg); return processMessage(&msg);
} else if (!msg.isMouseMsg()) { } else if (!msg.isMouseMsg()) {
g_vm->_filesManager->loadDrive(); g_vm->_filesManager->loadDrive();
} }
} }
return false;
} }
void CInputHandler::processMessage(CMessage *msg) { bool CInputHandler::processMessage(CMessage *msg) {
const CMouseMsg *mouseMsg = dynamic_cast<const CMouseMsg *>(msg); const CMouseMsg *mouseMsg = dynamic_cast<const CMouseMsg *>(msg);
_abortMessage = false; _abortMessage = false;
dispatchMessage(msg); bool handled = dispatchMessage(msg);
if (_abortMessage) { if (_abortMessage) {
_abortMessage = false; _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(); CPetControl *pet = _gameManager->_project->getPetControl();
if (!pet || !msg->execute(pet, nullptr, MSGFLAG_BREAK_IF_HANDLED)) { if (!pet || !msg->execute(pet, nullptr, MSGFLAG_BREAK_IF_HANDLED)) {
CViewItem *view = _gameManager->getView(); CViewItem *view = _gameManager->getView();
msg->execute(view); return msg->execute(view);
} }
return true;
} }
CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) { CGameObject *CInputHandler::dragEnd(const Point &pt, CTreeItem *dragItem) {

View File

@ -35,13 +35,15 @@ class CInputHandler {
private: private:
/** /**
* Process and dispatch a passed message * 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 * 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 * Called when a drag operation has ended
@ -76,7 +78,7 @@ public:
/** /**
* Handles a genereated mouse message * 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 * Returns true if input is locked

View File

@ -86,13 +86,15 @@ void CInputTranslator::mouseWheel(bool wheelUp, const Point &pt) {
} }
void CInputTranslator::keyDown(const Common::KeyState &keyState) { void CInputTranslator::keyDown(const Common::KeyState &keyState) {
if (isSpecialKey(keyState.keycode)) {
CVirtualKeyCharMsg msg(keyState);
_inputHandler->handleMessage(msg);
}
if (keyState.ascii > 0 && keyState.ascii <= 127) { if (keyState.ascii > 0 && keyState.ascii <= 127) {
CKeyCharMsg msg(keyState.ascii); CKeyCharMsg msg(keyState.ascii);
if (_inputHandler->handleMessage(msg))
return;
}
if (isSpecialKey(keyState.keycode)) {
CVirtualKeyCharMsg msg(keyState);
msg._keyState.ascii = 0;
_inputHandler->handleMessage(msg); _inputHandler->handleMessage(msg);
} }
} }