Fix menu overshoots hopefully finally.

This commit is contained in:
Johannes Mockenhaupt 2017-11-23 11:09:10 +01:00
parent 5b9fd6fd78
commit 90611a1792
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -639,9 +639,8 @@ public class RuffyScripter implements RuffyCommands {
public void navigateToMenu(MenuType desiredMenu) { public void navigateToMenu(MenuType desiredMenu) {
int retries = 20; int retries = 20;
MenuType lastSeenMenu = getCurrentMenu().getType(); MenuType lastSeenMenu = getCurrentMenu().getType();
while (getCurrentMenu().getType() != desiredMenu) { while (lastSeenMenu != desiredMenu) {
MenuType currentMenuType = getCurrentMenu().getType(); log.debug("Navigating to menu " + desiredMenu + ", current menu: " + lastSeenMenu);
log.debug("Navigating to menu " + desiredMenu + ", current menu: " + currentMenuType);
retries--; retries--;
if (retries == 0) { if (retries == 0) {
throw new CommandException("Menu not found searching for " + desiredMenu throw new CommandException("Menu not found searching for " + desiredMenu
@ -650,8 +649,10 @@ public class RuffyScripter implements RuffyCommands {
pressMenuKey(); pressMenuKey();
// sometimes the pump takes a bit longer (more than one screen refresh) to advance // sometimes the pump takes a bit longer (more than one screen refresh) to advance
// to the next menu. wait until we actually see the change to avoid overshoots. // to the next menu. wait until we actually see the change to avoid overshoots.
while (getCurrentMenu().getType() == lastSeenMenu) { MenuType next = getCurrentMenu().getType();
while (next == lastSeenMenu) {
waitForScreenUpdate(); waitForScreenUpdate();
next = getCurrentMenu().getType();
} }
lastSeenMenu = getCurrentMenu().getType(); lastSeenMenu = getCurrentMenu().getType();
} }