Added view online button to booklet

This commit is contained in:
Ellpeck 2016-05-29 22:11:18 +02:00
parent da0f071d58
commit af67fb87cc
3 changed files with 18 additions and 2 deletions

View file

@ -266,6 +266,8 @@ public class BookletUtils{
booklet.buttonForward.visible = booklet.currentEntrySet.getPageInIndex() < booklet.indexPageAmount; booklet.buttonForward.visible = booklet.currentEntrySet.getPageInIndex() < booklet.indexPageAmount;
booklet.buttonBackward.visible = booklet.currentEntrySet.getPageInIndex() > 1; booklet.buttonBackward.visible = booklet.currentEntrySet.getPageInIndex() > 1;
booklet.buttonViewOnline.visible = false;
for(int i = 0; i < booklet.chapterButtons.length; i++){ for(int i = 0; i < booklet.chapterButtons.length; i++){
IndexButton button = (IndexButton)booklet.chapterButtons[i]; IndexButton button = (IndexButton)booklet.chapterButtons[i];
if(entry == null){ if(entry == null){
@ -335,6 +337,8 @@ public class BookletUtils{
booklet.buttonBackward.visible = getPrevPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null; booklet.buttonBackward.visible = getPrevPage(chapter, booklet.currentEntrySet.getCurrentPage()) != null;
booklet.buttonPreviousScreen.visible = true; booklet.buttonPreviousScreen.visible = true;
booklet.buttonViewOnline.visible = true;
for(GuiButton chapterButton : booklet.chapterButtons){ for(GuiButton chapterButton : booklet.chapterButtons){
chapterButton.visible = false; chapterButton.visible = false;
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.booklet;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.BookletPage; import de.ellpeck.actuallyadditions.api.booklet.BookletPage;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.internal.IEntrySet; import de.ellpeck.actuallyadditions.api.internal.IEntrySet;
import de.ellpeck.actuallyadditions.api.internal.IBookletGui; import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton; import de.ellpeck.actuallyadditions.mod.booklet.button.BookmarkButton;
@ -78,6 +79,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
public GuiButton buttonConfig; public GuiButton buttonConfig;
public GuiButton buttonWebsite; public GuiButton buttonWebsite;
public GuiButton buttonPatreon; public GuiButton buttonPatreon;
public GuiButton buttonViewOnline;
public final GuiButton[] chapterButtons = new GuiButton[CHAPTER_BUTTONS_AMOUNT]; public final GuiButton[] chapterButtons = new GuiButton[CHAPTER_BUTTONS_AMOUNT];
public final GuiButton[] bookmarkButtons = new GuiButton[8]; public final GuiButton[] bookmarkButtons = new GuiButton[8];
public GuiTextField searchField; public GuiTextField searchField;
@ -229,6 +231,13 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
BookletUtils.openBrowser(UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK); BookletUtils.openBrowser(UpdateChecker.CHANGELOG_LINK, UpdateChecker.DOWNLOAD_LINK);
} }
} }
//Handles View Online
else if(button == this.buttonViewOnline){
IBookletChapter chapter = this.currentEntrySet.getCurrentChapter();
if(chapter != null){
BookletUtils.openBrowser("http://ellpeck.de/actaddmanual/#"+chapter.getUnlocalizedName());
}
}
//Handles Website //Handles Website
else if(button == this.buttonWebsite){ else if(button == this.buttonWebsite){
BookletUtils.openBrowser("http://ellpeck.de"); BookletUtils.openBrowser("http://ellpeck.de");
@ -302,7 +311,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
updateHover.add(StringUtil.localize("info."+ModUtil.MOD_ID+".update.buttonOptions")); updateHover.add(StringUtil.localize("info."+ModUtil.MOD_ID+".update.buttonOptions"));
} }
this.buttonUpdate = new TexturedButton(4, this.guiLeft-11, this.guiTop-11, 245, 0, 11, 11, updateHover); this.buttonUpdate = new TexturedButton(4, this.guiLeft-11, this.guiTop-11, 245, 0, 11, 11, updateHover);
this.buttonUpdate.visible = UpdateChecker.needsUpdateNotify; this.buttonUpdate.visible = UpdateChecker.needsUpdateNotify || UpdateChecker.checkFailed;
this.buttonList.add(this.buttonUpdate); this.buttonList.add(this.buttonUpdate);
this.buttonTwitter = new TexturedButton(5, this.guiLeft, this.guiTop+10, 213, 0, 8, 8, Collections.singletonList(TextFormatting.GOLD+"Open @ActAddMod on Twitter in Browser")); this.buttonTwitter = new TexturedButton(5, this.guiLeft, this.guiTop+10, 213, 0, 8, 8, Collections.singletonList(TextFormatting.GOLD+"Open @ActAddMod on Twitter in Browser"));
@ -327,6 +336,9 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
this.buttonPatreon = new TexturedButton(-100, this.guiLeft, this.guiTop, 237, 0, 8, 8, patreonHover); this.buttonPatreon = new TexturedButton(-100, this.guiLeft, this.guiTop, 237, 0, 8, 8, patreonHover);
this.buttonList.add(this.buttonPatreon); this.buttonList.add(this.buttonPatreon);
this.buttonViewOnline = new TexturedButton(-101, this.guiLeft+146, this.guiTop+180, 245, 44, 11, 11, Collections.singletonList(TextFormatting.GOLD+"View Online"));
this.buttonList.add(this.buttonViewOnline);
ArrayList configHover = new ArrayList(); ArrayList configHover = new ArrayList();
configHover.add(TextFormatting.GOLD+"Show Configuration GUI"); configHover.add(TextFormatting.GOLD+"Show Configuration GUI");
configHover.addAll(this.fontRendererObj.listFormattedStringToWidth("It is highly recommended that you restart your game after changing anything as that prevents possible bugs occuring!", 200)); configHover.addAll(this.fontRendererObj.listFormattedStringToWidth("It is highly recommended that you restart your game after changing anything as that prevents possible bugs occuring!", 200));
@ -395,7 +407,7 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
this.currentEntrySet.getCurrentPage().updateScreen(this.ticksElapsed); this.currentEntrySet.getCurrentPage().updateScreen(this.ticksElapsed);
} }
boolean buttonThere = UpdateChecker.needsUpdateNotify; boolean buttonThere = UpdateChecker.needsUpdateNotify || UpdateChecker.checkFailed;
this.buttonUpdate.visible = buttonThere; this.buttonUpdate.visible = buttonThere;
if(buttonThere){ if(buttonThere){
if(this.ticksElapsed%8 == 0){ if(this.ticksElapsed%8 == 0){

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB