From 9e848e8e64103406a7e356081f18d9c597b0018d Mon Sep 17 00:00:00 2001 From: uruk Date: Mon, 2 Sep 2013 15:44:55 +0200 Subject: [PATCH] AVALANCHE: Upgrade drop-down menu. (Now it's complete.) Fix Trip::neardoor(). --- engines/avalanche/avalanche.cpp | 2 +- engines/avalanche/dropdown2.cpp | 15 +++++++++++---- engines/avalanche/trip6.cpp | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index 0c5869efbe3..73b39d64074 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -532,7 +532,7 @@ void AvalancheEngine::updateEvents() { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_LBUTTONDOWN: - _lucerna->holdLeftMouse = true; // Used in Lucerna::checkclick() and Dropdown::checkclick(). + _lucerna->holdLeftMouse = true; // Used in Lucerna::checkclick() and Dropdown::menu_link(). break; case Common::EVENT_LBUTTONUP: _lucerna->holdLeftMouse = false; // Same as above. diff --git a/engines/avalanche/dropdown2.cpp b/engines/avalanche/dropdown2.cpp index 4647f5947ad..baf1e94edf6 100644 --- a/engines/avalanche/dropdown2.cpp +++ b/engines/avalanche/dropdown2.cpp @@ -863,7 +863,8 @@ void Dropdown::menu_link() { // TODO: Optimize it ASAP!!! It really needs it... if (_vm->_lucerna->holdLeftMouse) { if (cursorPos.y > 21) { if (!((ddm_o.firstlix) && ((cursorPos.x >= ddm_o.flx1 * 8) && (cursorPos.x <= ddm_o.flx2 * 8) - && (cursorPos.y >= 24) && (cursorPos.y <= (ddm_o.fly * 2 + 1))))) { // Clicked OUTSIDE the menu. + && (cursorPos.y >= 24) && (cursorPos.y <= (ddm_o.fly * 2 + 1))))) { + // Clicked OUTSIDE the menu. if (ddm_o.menunow) { ddm_o.wipe(); _vm->_lucerna->holdLeftMouse = false; @@ -874,9 +875,16 @@ void Dropdown::menu_link() { // TODO: Optimize it ASAP!!! It really needs it... // Clicked on menu bar. if (ddm_o.menunow) { ddm_o.wipe(); - _vm->_lucerna->holdLeftMouse = true; _vm->_graphics->_surface.copyFrom(backup); _vm->_graphics->refreshScreen(); + _vm->_lucerna->holdLeftMouse = true; + + if (((ddm_o.left * 8) <= cursorPos.x) && (cursorPos.x <= (ddm_o.left * 8 + 80))) { // 80: the width of one menu item on the bar in pixels. + // If we clicked on the same menu item on the bar... + _vm->_lucerna->holdLeftMouse = false; + return; + } + break; } } @@ -885,8 +893,7 @@ void Dropdown::menu_link() { // TODO: Optimize it ASAP!!! It really needs it... if ((ddm_o.firstlix) && ((cursorPos.x >= ddm_o.flx1 * 8) && (cursorPos.x <= ddm_o.flx2 * 8) && (cursorPos.y >= 12) && (cursorPos.y <= (ddm_o.fly * 2 + 1)))) { - // We act only if the button is relased over a menu item. - Common::Event event; + // We act only if the button is released over a menu item. while (!_vm->shouldQuit()) { cursorPos = _vm->getMousePos(); ddm_o.lightup(cursorPos); diff --git a/engines/avalanche/trip6.cpp b/engines/avalanche/trip6.cpp index f83bfc07b99..5e42839e93f 100644 --- a/engines/avalanche/trip6.cpp +++ b/engines/avalanche/trip6.cpp @@ -1573,7 +1573,7 @@ bool Trip::infield(byte which) { } bool Trip::neardoor() { - if (_vm->_gyro->numfields < 9) { + if (_vm->_gyro->numfields < 8) { /* there ARE no doors here! */ return false; } @@ -1581,7 +1581,7 @@ bool Trip::neardoor() { int16 ux = tr[0].x; int16 uy = tr[0].y + tr[0]._info.yl; bool nd = false; - for (byte fv = 9; fv <= _vm->_gyro->numfields; fv++) + for (byte fv = 8; fv < _vm->_gyro->numfields; fv++) if ((ux >= _vm->_gyro->fields[fv].x1) && (ux <= _vm->_gyro->fields[fv].x2) && (uy >= _vm->_gyro->fields[fv].y1) && (uy <= _vm->_gyro->fields[fv].y2)) nd = true;