From 8fd1de84e4fd4e4e491db7834db2f5d2e8b5e819 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Sat, 19 Jun 2021 16:19:22 +0100 Subject: [PATCH] Fix next/previous section button weirdness --- .../gui/handbook/GuiWizardHandbook.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/main/java/electroblob/wizardry/client/gui/handbook/GuiWizardHandbook.java b/src/main/java/electroblob/wizardry/client/gui/handbook/GuiWizardHandbook.java index b68c4756..b89dcd77 100644 --- a/src/main/java/electroblob/wizardry/client/gui/handbook/GuiWizardHandbook.java +++ b/src/main/java/electroblob/wizardry/client/gui/handbook/GuiWizardHandbook.java @@ -496,24 +496,30 @@ public class GuiWizardHandbook extends GuiScreen { Section currentSection = null; - for(Section section : sections.values()){ - // We always want this button to do something, and taking the right-hand page means it always does - if(section.containsPage(doubleToSinglePage(currentPage, true))){ - currentSection = section; - break; + if(currentPage < singleToDoublePage(pageCount)){ + // Find current section + for(Section section : sections.values()){ + // Take the right-hand page if going to the next section, and the left-hand page otherwise + if(section.containsPage(doubleToSinglePage(currentPage, button == nextSection))){ + currentSection = section; + break; + } } } - if(currentSection != null){ + List
visibleSections = new ArrayList<>(sectionList); + visibleSections.removeIf(s -> !s.isUnlocked()); - List
visibleSections = new ArrayList<>(sectionList); - visibleSections.removeIf(s -> !s.isUnlocked()); + int index = currentSection == null ? visibleSections.size() : visibleSections.indexOf(currentSection); - int index = visibleSections.indexOf(currentSection); - - if(button == nextSection && index + 1 < visibleSections.size()){ + if(button == nextSection){ + if(index + 1 < visibleSections.size()){ 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); } }