From 094382a6d0053078851ab42ca3aabd5ac350df48 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sun, 26 Feb 2006 15:24:11 +0000 Subject: With the added delay to the popup menu loop, it's much more likely that each iteration will see several events, so pop all events from the queue each time. Of course, we still only need to check the mouse position once. Warp the mouse back to neutral even if we're trying to go past the first/last menu entry. svn-id: r20918 --- engines/lure/menu.cpp | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'engines/lure/menu.cpp') diff --git a/engines/lure/menu.cpp b/engines/lure/menu.cpp index 9fa98d5300..8051e14fac 100644 --- a/engines/lure/menu.cpp +++ b/engines/lure/menu.cpp @@ -365,13 +365,13 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { refreshFlag = false; } - if (e.pollEvent()) { + while (e.pollEvent()) { if (e.quitFlag) { selectedIndex = 0xffff; - break; + goto bail_out; } - if (e.type() == OSystem::EVENT_KEYDOWN) { + else if (e.type() == OSystem::EVENT_KEYDOWN) { byte ch = e.event().kbd.ascii; uint16 keycode = e.event().kbd.keycode; @@ -383,38 +383,46 @@ uint16 PopupMenu::Show(int numEntries, const char *actions[]) { ++selectedIndex; refreshFlag = true; } else if ((ch == '\xd') || (keycode == 0x10f)) { - break; + goto bail_out; } else if (ch == '\x1b') { selectedIndex = 0xffff; - break; - } - - } else if (e.type() == OSystem::EVENT_MOUSEMOVE) { - if ((mouse.y() < yMiddle) && (selectedIndex > 0) && - (yMiddle-mouse.y() >= POPMENU_CHANGE_SENSITIVITY)) { - --selectedIndex; - mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle); - refreshFlag = true; - } else if ((mouse.y() > yMiddle) && (selectedIndex < numEntries - 1) && - (mouse.y()-yMiddle >= POPMENU_CHANGE_SENSITIVITY)) { - ++selectedIndex; - mouse.setPosition(FULL_SCREEN_WIDTH/2, yMiddle); - refreshFlag = true; + goto bail_out; } } else if (e.type() == OSystem::EVENT_LBUTTONDOWN) { mouse.waitForRelease(); - break; + goto bail_out; } else if (e.type() == OSystem::EVENT_RBUTTONDOWN) { mouse.waitForRelease(); selectedIndex = 0xffff; - break; + goto bail_out; } } + + // Warping the mouse to "neutral" even if the top/bottom menu + // entry has been reached has both pros and cons. It makes the + // menu behave a bit more sensibly, but it also makes it harder + // to move the mouse pointer out of the ScummVM window. + + if (mouse.y() < yMiddle - POPMENU_CHANGE_SENSITIVITY) { + if (selectedIndex > 0) { + --selectedIndex; + refreshFlag = true; + } + mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle); + } else if (mouse.y() > yMiddle + POPMENU_CHANGE_SENSITIVITY) { + if (selectedIndex < numEntries - 1) { + ++selectedIndex; + refreshFlag = true; + } + mouse.setPosition(FULL_SCREEN_WIDTH / 2, yMiddle); + } + system.delayMillis(20); } +bail_out: mouse.setPosition(oldX, oldY); mouse.cursorOn(); screen.update(); -- cgit v1.2.3