diff options
author | Joseph-Eugene Winzer | 2017-12-21 03:56:28 +0100 |
---|---|---|
committer | Thierry Crozat | 2018-01-23 02:15:44 +0000 |
commit | acfe2ab145eeccd3129f18a10120b3bc5259696d (patch) | |
tree | 059f76b89dd0d86098e568865a64efc4a4bca5a4 | |
parent | 639bc10906042d8c3950962e47812a61764c6af4 (diff) | |
download | scummvm-rg350-acfe2ab145eeccd3129f18a10120b3bc5259696d.tar.gz scummvm-rg350-acfe2ab145eeccd3129f18a10120b3bc5259696d.tar.bz2 scummvm-rg350-acfe2ab145eeccd3129f18a10120b3bc5259696d.zip |
SUPERNOVA: Registers cmdButton clicks
Mouse clicks were consumed if a message was shown. This commit
introduces an exception for clicks on command buttons.
Also some refactoring.
-rw-r--r-- | engines/supernova/state.cpp | 96 |
1 files changed, 80 insertions, 16 deletions
diff --git a/engines/supernova/state.cpp b/engines/supernova/state.cpp index bfd0951eac..8871721065 100644 --- a/engines/supernova/state.cpp +++ b/engines/supernova/state.cpp @@ -528,15 +528,40 @@ void GameManager::resetInputState() { } void GameManager::processInput() { + enum { + onNone, + onObject, + onCmdButton, + onInventory, + onInventoryArrowUp, + onInventoryArrowDown + } mouseLocation; + + if (_mouseField >= 0 && _mouseField < 256) + mouseLocation = onObject; + else if (_mouseField >= 256 && _mouseField < 512) + mouseLocation = onCmdButton; + else if (_mouseField >= 512 && _mouseField < 768) + mouseLocation = onInventory; + else if (_mouseField == 768) + mouseLocation = onInventoryArrowUp; + else if (_mouseField == 769) + mouseLocation = onInventoryArrowDown; + else + mouseLocation = onNone; + if (_mouseClickType == Common::EVENT_LBUTTONUP) { if (_vm->_messageDisplayed) { // Hide the message and consume the event _vm->removeMessage(); - return; + if (mouseLocation != onCmdButton) + return; } - if (((_mouseField >= 0) && (_mouseField < 256)) || - ((_mouseField >= 512) && (_mouseField < 768))) { + switch(mouseLocation) { + case onObject: + case onInventory: + // Fallthrough if (_inputVerb == ACTION_GIVE || _inputVerb == ACTION_USE) { if (Object::isNullObject(_inputObject[0])) { _inputObject[0] = _currentInputObject; @@ -551,27 +576,34 @@ void GameManager::processInput() { if (!Object::isNullObject(_currentInputObject)) _processInput = true; } - } else if (_mouseField >= 256 && _mouseField < 512) { + break; + case onCmdButton: resetInputState(); _inputVerb = static_cast<Action>(_mouseField - 256); - } else if (_mouseField == 768) { + break; + case onInventoryArrowUp: if (_inventoryScroll >= 2) _inventoryScroll -= 2; - } else if (_mouseField == 769) { + break; + case onInventoryArrowDown: if (_inventoryScroll < _inventory.getSize() - ARRAYSIZE(_guiInventory)) _inventoryScroll += 2; + break; + case onNone: + break; } + } else if (_mouseClickType == Common::EVENT_RBUTTONUP) { if (_vm->_messageDisplayed) { // Hide the message and consume the event _vm->removeMessage(); return; } + if (Object::isNullObject(_currentInputObject)) return; - if (((_mouseField >= 0) && (_mouseField < 256)) || - ((_mouseField >= 512) && (_mouseField < 768))) { + if (mouseLocation == onObject || mouseLocation == onInventory) { _inputObject[0] = _currentInputObject; ObjectTypes type = _inputObject[0]->_type; if (type & OPENABLE) @@ -628,27 +660,59 @@ void GameManager::processInput() { } if (_mouseField != field) { - if (_mouseField >= 768) + switch (mouseLocation) { + case onInventoryArrowUp: + case onInventoryArrowDown: + // Fallthrough _guiInventoryArrow[_mouseField - 768].setHighlight(false); - else if (_mouseField >= 512) + break; + case onInventory: _guiInventory[_mouseField - 512].setHighlight(false); - else if (_mouseField >= 256) + break; + case onCmdButton: _guiCommandButton[_mouseField - 256].setHighlight(false); - else if (_mouseField != -1) { + break; + case onObject: + case onNone: + // Fallthrough + break; } Object::setObjectNull(_currentInputObject); _mouseField = field; - if (_mouseField >= 768) + if (_mouseField >= 0 && _mouseField < 256) + mouseLocation = onObject; + else if (_mouseField >= 256 && _mouseField < 512) + mouseLocation = onCmdButton; + else if (_mouseField >= 512 && _mouseField < 768) + mouseLocation = onInventory; + else if (_mouseField == 768) + mouseLocation = onInventoryArrowUp; + else if (_mouseField == 769) + mouseLocation = onInventoryArrowDown; + else + mouseLocation = onNone; + + switch (mouseLocation) { + case onInventoryArrowUp: + case onInventoryArrowDown: + // Fallthrough _guiInventoryArrow[_mouseField - 768].setHighlight(true); - else if (_mouseField >= 512) { + break; + case onInventory: _guiInventory[_mouseField - 512].setHighlight(true); _currentInputObject = _inventory.get(_mouseField - 512 + _inventoryScroll); - } else if (_mouseField >= 256) + break; + case onCmdButton: _guiCommandButton[_mouseField - 256].setHighlight(true); - else if (_mouseField != -1) + break; + case onObject: _currentInputObject = _currentRoom->getObject(_mouseField); + break; + case onNone: + break; + } } } } |