[Scummvm-cvs-logs] SF.net SVN: scummvm: [20918] scummvm/trunk/engines/lure/menu.cpp

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sun Feb 26 07:25:03 CET 2006


Revision: 20918
Author:   eriktorbjorn
Date:     2006-02-26 07:24:11 -0800 (Sun, 26 Feb 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=20918&view=rev

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/engines/lure/menu.cpp
Modified: scummvm/trunk/engines/lure/menu.cpp
===================================================================
--- scummvm/trunk/engines/lure/menu.cpp	2006-02-26 15:21:21 UTC (rev 20917)
+++ scummvm/trunk/engines/lure/menu.cpp	2006-02-26 15:24:11 UTC (rev 20918)
@@ -365,13 +365,13 @@
 			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 @@
 					++selectedIndex;
 					refreshFlag = true;
 				} else if ((ch == '\xd') || (keycode == 0x10f)) {
-					break;
+					goto bail_out;
 				} else if (ch == '\x1b') {
 					selectedIndex = 0xffff;
-					break;
+					goto bail_out;
 				}
 
-			} 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;
-				}
-
 			} 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();







More information about the Scummvm-git-logs mailing list