RuffyScripter.navigateToMenu: detect if we're wrapping around not finding a menu (likely because it's hidden)

This commit is contained in:
Johannes Mockenhaupt 2017-07-15 17:09:04 +02:00
parent 7e538cbcf6
commit 9653af5501
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -282,19 +282,17 @@ public class RuffyScripter {
} }
public void navigateToMenu(MenuType desiredMenu) { public void navigateToMenu(MenuType desiredMenu) {
// TODO menu var might not have been initialized if this is called to early
// though that's gonna be a problem for all code;
// wait during init till this is set? create a getter for currentMenu to do this?
MenuType startedFrom = currentMenu.getType(); MenuType startedFrom = currentMenu.getType();
boolean movedOnce = false;
while (currentMenu.getType() != desiredMenu) { while (currentMenu.getType() != desiredMenu) {
MenuType currentType = currentMenu.getType(); MenuType currentMenuType = currentMenu.getType();
/* if (currentType == startedFrom) { if (movedOnce && currentMenuType == startedFrom) {
// TODO don't trigger right away, that's always a match ;-) throw new CommandException().message("Menu not found searching for " + desiredMenu
// failed to find the menu, after going through all the menus, bail out + ". Check menu settings on your pump to ensure it's not hidden.");
throw new CommandException(false, null, "Menu not found searching for " + desiredMenu); }
}*/
pressMenuKey(); pressMenuKey();
waitForMenuToBeLeft(currentType); waitForMenuToBeLeft(currentMenuType);
movedOnce = true;
} }
} }