diff options
author | Strangerke | 2012-06-01 23:57:25 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-03-28 17:36:57 +0200 |
commit | 5f3a3039512c60b6a664c83da03c478d54ffd400 (patch) | |
tree | 2e3f26478019cccc3483026286c3110b163245f4 | |
parent | 747734a6975dcdabb703d994a3210762d733721b (diff) | |
download | scummvm-rg350-5f3a3039512c60b6a664c83da03c478d54ffd400.tar.gz scummvm-rg350-5f3a3039512c60b6a664c83da03c478d54ffd400.tar.bz2 scummvm-rg350-5f3a3039512c60b6a664c83da03c478d54ffd400.zip |
LILLIPUT: Modify mouse handling to stick to original behavior
-rw-r--r-- | engines/lilliput/lilliput.cpp | 92 | ||||
-rw-r--r-- | engines/lilliput/lilliput.h | 3 | ||||
-rw-r--r-- | engines/lilliput/script.cpp | 4 |
3 files changed, 70 insertions, 29 deletions
diff --git a/engines/lilliput/lilliput.cpp b/engines/lilliput/lilliput.cpp index 7191b10332..d0b77013bf 100644 --- a/engines/lilliput/lilliput.cpp +++ b/engines/lilliput/lilliput.cpp @@ -121,7 +121,9 @@ LilliputEngine::LilliputEngine(OSystem *syst, const LilliputGameDescription *gd) _oldMousePos = Common::Point(0, 0); _mouseDisplayPos = Common::Point(0, 0); _mouseButton = 0; + _mouseClicked = false; _savedMousePosDivided = Common::Point(-1, -1); + _mousePreviousEventType = Common::EVENT_INVALID; _skipDisplayFlag1 = 1; _skipDisplayFlag2 = 0; _displayMap = false; @@ -1007,7 +1009,7 @@ void LilliputEngine::checkMapClosing(bool &forceReturnFl) { _keyboard_getch(); return; } else { - if ((_mouseButton & 1) == 0) + if (_mouseButton != 1) return; _mouseButton = 0; @@ -1879,26 +1881,53 @@ void LilliputEngine::sub12F37() { } } +void LilliputEngine::sub13156(bool &forceReturnFl) { + debugC(2, kDebugEngine, "sub13156()"); + + forceReturnFl = false; + + if (!_keyboard_checkKeyboard()) + return; + + Common::KeyState state = _keyboard_getch(); + uint16 var1 = state.ascii; + for (int i = 0; i < 20; i++) { + warning("%d - 0x%x", i, _rulesBuffer13_4[i]); + } + + // TODO: Very incomplete! + + // sub1305C(); + forceReturnFl = true; + +} + void LilliputEngine::sub130EE() { debugC(2, kDebugEngine, "sub130EE()"); // warning("sub147D7"); -// warning("sub13156"); - - if (_mouseButton == 0) - // TODO: check _mouse_clicked + bool forceReturnFl = false; + sub13156(forceReturnFl); + if (forceReturnFl) return; + if (_mouseButton == 0) { + if (!_mouseClicked) + return; + _mouseClicked = false; + _mouseButton = 2; + } + int button = _mouseButton; _mouseButton = 0; - if (button & 2) { + if (button == 2) { if (_lastInterfaceHotspotIndex != -1) sub1305C(_lastInterfaceHotspotIndex, button); return; } - bool forceReturnFl = false; + forceReturnFl = false; checkInterfaceHotspots(forceReturnFl); if (forceReturnFl) return; @@ -1986,7 +2015,7 @@ void LilliputEngine::sub1305C(byte index, byte button) { _lastInterfaceHotspotIndex = index; _lastInterfaceHotspotButton = button; - if (button &= 2) { + if (button == 2) { if (_byte12FCE != 1) { _scriptHandler->_interfaceHotspotStatus[index] = kHotspotEnabled; _byte16F07_menuId = 2; @@ -2323,14 +2352,34 @@ void LilliputEngine::pollEvent() { while (_system->getEventManager()->pollEvent(event)) { switch (event.type) { case Common::EVENT_MOUSEMOVE: - _mousePos.x = CLIP<int>(event.mouse.x, 0, 304) + 5; - _mousePos.y = CLIP<int>(event.mouse.y, 0, 184) + 1; - break; - case Common::EVENT_LBUTTONUP: - _mouseButton |= 1; - break; - case Common::EVENT_RBUTTONUP: - _mouseButton |= 2; + case Common::EVENT_LBUTTONDOWN: + case Common::EVENT_LBUTTONUP: { + Common::Point newMousePos = Common::Point(CLIP<int>(event.mouse.x, 0, 304), CLIP<int>(event.mouse.y, 0, 184)); + + if (_mousePreviousEventType != event.type) { + _mousePreviousEventType = event.type; + if (_mouseButton != 1) { + _mouseButton = 2; + if (event.type != Common::EVENT_MOUSEMOVE) { + _mouseButton = 1; + _mousePos = Common::Point(newMousePos.x + 5, newMousePos.y + 1); + } + } else { + _mouseClicked = true; + } + } + + if (newMousePos != _oldMousePos) { + _oldMousePos = newMousePos; + if (_skipDisplayFlag1 != 0) { + restoreSurfaceUnderMousePointer(); + _mouseDisplayPos = newMousePos; + displayMousePointer(); + } else { + _mouseDisplayPos = newMousePos; + } + } + } break; case Common::EVENT_QUIT: _shouldQuit = true; @@ -2351,17 +2400,6 @@ void LilliputEngine::pollEvent() { break; } } - - if (_mousePos != _oldMousePos) { - _oldMousePos = _mousePos; - if (_skipDisplayFlag1 != 0) { - restoreSurfaceUnderMousePointer(); - _mouseDisplayPos = _mousePos; - displayMousePointer(); - } else { - _mouseDisplayPos = _mousePos; - } - } } byte *LilliputEngine::loadVGA(Common::String filename, int expectedSize, bool loadPal) { diff --git a/engines/lilliput/lilliput.h b/engines/lilliput/lilliput.h index 5cf577084e..d1878e8afe 100644 --- a/engines/lilliput/lilliput.h +++ b/engines/lilliput/lilliput.h @@ -272,6 +272,7 @@ public: void renderCharacters(byte *buf, Common::Point pos); + void sub13156(bool &forceReturnFl); byte sub16799(int index, Common::Point param1); byte getDirection(Common::Point param1, Common::Point param2); void addCharToBuf(byte character); @@ -337,6 +338,8 @@ public: Common::Point _oldMousePos; Common::Point _mouseDisplayPos; int _mouseButton; + bool _mouseClicked; + Common::EventType _mousePreviousEventType; Common::Point _savedMousePosDivided; int _skipDisplayFlag1; int _skipDisplayFlag2; diff --git a/engines/lilliput/script.cpp b/engines/lilliput/script.cpp index 3138779ed7..42679b056d 100644 --- a/engines/lilliput/script.cpp +++ b/engines/lilliput/script.cpp @@ -3050,7 +3050,7 @@ void LilliputScript::OC_waitForEvent() { _vm->_keyboard_getch(); break;; } - if (_vm->_mouseButton & 1) + if (_vm->_mouseButton == 1) break; _vm->update(); @@ -3183,7 +3183,7 @@ void LilliputScript::OC_displayTitleScreen() { break; } - if (_vm->_mouseButton & 1) + if (_vm->_mouseButton == 1) break; if ((_vm->_byte184F4 != 0) && (_vm->_sound_byte16F06 == 0)) |