fix menu hiding items cause derpings in detecting current hovering option

This commit is contained in:
yugecin 2016-12-04 16:06:13 +01:00
parent 403075a53d
commit 8b1d1e03bb
2 changed files with 14 additions and 14 deletions

View File

@ -609,14 +609,14 @@ public class OptionsMenu extends BasicGameState {
if (index >= currentTab.options.length)
return null;
int i = index;
while (i >= 0) {
if (!currentTab.options[i--].showCondition()) {
if (++index >= currentTab.options.length) {
return null;
}
for (GameOption option : currentTab.options) {
if (option.showCondition()) {
index--;
}
if (index < 0) {
return option;
}
}
return currentTab.options[index];
return null;
}
}

View File

@ -130,15 +130,15 @@ public class OptionsOverlay {
if (index >= options.length) {
return -1;
}
int i = index;
while (i >= 0) {
if (!options[i--].showCondition()) {
if (++index >= options.length) {
return -1;
}
for (int i = 0; i < options.length; i++) {
if (options[i].showCondition()) {
index--;
}
if (index < 0) {
return i;
}
}
return index;
return -1;
}
public void update(int mouseX, int mouseY) {