From 99878a1eef65baf9931e582f348d4a6f1c1efee0 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 28 Sep 2015 22:26:43 +0200 Subject: [PATCH] Made forward and backward button visibility calculation less stupid --- .../actuallyadditions/booklet/GuiBooklet.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java index fe6ff9f40..2afd2fe8e 100644 --- a/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java +++ b/src/main/java/ellpeck/actuallyadditions/booklet/GuiBooklet.java @@ -375,6 +375,9 @@ public class GuiBooklet extends GuiScreen{ if(this.currentPage != null){ BookletPage page = this.getNextPage(this.currentChapter, this.currentPage); if(page != null) this.currentPage = page; + + this.getButton(BUTTON_FORWARD_ID).visible = this.getNextPage(this.currentChapter, this.currentPage) != null; + this.getButton(BUTTON_BACK_ID).visible = this.getPrevPage(this.currentChapter, this.currentPage) != null; } else{ this.openIndexEntry(this.currentIndexEntry, this.pageOpenInIndex+1, !(this.currentIndexEntry instanceof BookletEntryAllSearch)); @@ -386,6 +389,9 @@ public class GuiBooklet extends GuiScreen{ if(this.currentPage != null){ BookletPage page = this.getPrevPage(this.currentChapter, this.currentPage); if(page != null) this.currentPage = page; + + this.getButton(BUTTON_FORWARD_ID).visible = this.getNextPage(this.currentChapter, this.currentPage) != null; + this.getButton(BUTTON_BACK_ID).visible = this.getPrevPage(this.currentChapter, this.currentPage) != null; } else{ this.openIndexEntry(this.currentIndexEntry, this.pageOpenInIndex-1, !(this.currentIndexEntry instanceof BookletEntryAllSearch)); @@ -416,15 +422,6 @@ public class GuiBooklet extends GuiScreen{ } } } - - if(button.id == BUTTON_FORWARD_ID || button.id == BUTTON_BACK_ID){ - if(this.currentChapter != null && this.currentIndexEntry != null){ - if(this.currentPage != null){ - this.getButton(BUTTON_FORWARD_ID).visible = this.getNextPage(this.currentChapter, this.currentPage) != null; - this.getButton(BUTTON_BACK_ID).visible = this.getPrevPage(this.currentChapter, this.currentPage) != null; - } - } - } } @SuppressWarnings("unchecked")