diff options
author | Torbjörn Andersson | 2006-02-26 15:24:11 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2006-02-26 15:24:11 +0000 |
commit | 094382a6d0053078851ab42ca3aabd5ac350df48 (patch) | |
tree | 404639798a1664892d4186da08befeb70c81dc38 | |
parent | d6170c87c46e7f622918e769ae2edacb792ab538 (diff) | |
download | scummvm-rg350-094382a6d0053078851ab42ca3aabd5ac350df48.tar.gz scummvm-rg350-094382a6d0053078851ab42ca3aabd5ac350df48.tar.bz2 scummvm-rg350-094382a6d0053078851ab42ca3aabd5ac350df48.zip |
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
-rw-r--r-- | engines/lure/menu.cpp | 48 |
1 files changed, 28 insertions, 20 deletions
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(); |