Fix next/previous section button weirdness

This commit is contained in:
Electroblob77
2021-06-19 16:19:22 +01:00
parent 95d9168b6b
commit 8fd1de84e4
@@ -496,24 +496,30 @@ public class GuiWizardHandbook extends GuiScreen {
Section currentSection = null; Section currentSection = null;
for(Section section : sections.values()){ if(currentPage < singleToDoublePage(pageCount)){
// We always want this button to do something, and taking the right-hand page means it always does // Find current section
if(section.containsPage(doubleToSinglePage(currentPage, true))){ for(Section section : sections.values()){
currentSection = section; // Take the right-hand page if going to the next section, and the left-hand page otherwise
break; if(section.containsPage(doubleToSinglePage(currentPage, button == nextSection))){
currentSection = section;
break;
}
} }
} }
if(currentSection != null){ List<Section> visibleSections = new ArrayList<>(sectionList);
visibleSections.removeIf(s -> !s.isUnlocked());
List<Section> visibleSections = new ArrayList<>(sectionList); int index = currentSection == null ? visibleSections.size() : visibleSections.indexOf(currentSection);
visibleSections.removeIf(s -> !s.isUnlocked());
int index = visibleSections.indexOf(currentSection); if(button == nextSection){
if(index + 1 < visibleSections.size()){
if(button == nextSection && index + 1 < visibleSections.size()){
currentPage = singleToDoublePage(visibleSections.get(index + 1).startPage); currentPage = singleToDoublePage(visibleSections.get(index + 1).startPage);
}else if(index > 0){ }else{
currentPage = singleToDoublePage(pageCount);
}
}else{
if(index > 0){
currentPage = singleToDoublePage(visibleSections.get(index - 1).startPage); currentPage = singleToDoublePage(visibleSections.get(index - 1).startPage);
} }
} }