diff --git a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java index 789e99875..bdfe0f55e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/api/booklet/IBookletPage.java @@ -59,6 +59,8 @@ public interface IBookletPage{ String getIdentifier(); + String getWebLink(); + IBookletPage addTextReplacement(String key, String value); IBookletPage addTextReplacement(String key, float value); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java index 6f2efbac1..e12ef792f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiMainPage.java @@ -14,8 +14,11 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry; import de.ellpeck.actuallyadditions.mod.booklet.InitBooklet; import de.ellpeck.actuallyadditions.mod.booklet.button.EntryButton; +import de.ellpeck.actuallyadditions.mod.booklet.misc.GuiAAAchievements; +import de.ellpeck.actuallyadditions.mod.config.GuiConfiguration; import de.ellpeck.actuallyadditions.mod.data.PlayerData; import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave; +import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; @@ -30,6 +33,8 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; @SideOnly(Side.CLIENT) @@ -46,9 +51,15 @@ public class GuiMainPage extends GuiBooklet{ "It's got some stuff I guess.@Ellpeck", "Actually Additions should be included in every new modpack that includes any form of tech.@KarillEndusa", "A mod that basically lets you do what ever the heck you want.@Joshwoo70", - "TINY TORCHES!! BABY TORCHES!! Somebody actually finally did it!!@Soaryn" + "TINY TORCHES!! BABY TORCHES!! Somebody actually finally did it!!@Soaryn", + "Balanced mod wich makes things different - in a good way.@garantiertnicht", + "The mod everyone needs, but not everyone knows@Brewpl", + "The in-game documentation is the best I’ve seen. I especially love the JEI integration. Even a derp like me can figure it out.@dannydjdk" }; + private TexturedButton achievementButton; + private TexturedButton configButton; + private GuiButton tutorialButton; private boolean showTutorial; @@ -86,6 +97,18 @@ public class GuiMainPage extends GuiBooklet{ this.buttonList.add(this.tutorialButton); } + List configText = new ArrayList(); + configText.add(TextFormatting.GOLD+"Open Config GUI"); + configText.addAll(this.fontRendererObj.listFormattedStringToWidth("Press this to configure "+ModUtil.NAME+" in-game. \nSome changes will require a game restart!", 200)); + this.configButton = new TexturedButton(RES_LOC_GADGETS, -388, this.guiLeft+16, this.guiTop+this.ySize-30, 188, 14, 16, 16, configText); + this.buttonList.add(this.configButton); + + List achievementText = new ArrayList(); + achievementText.add(TextFormatting.GOLD+"Open Achievements"); + achievementText.addAll(this.fontRendererObj.listFormattedStringToWidth("Press this to open the "+ModUtil.NAME+" Achievements.", 200)); + this.achievementButton = new TexturedButton(RES_LOC_GADGETS, -389, this.guiLeft+36, this.guiTop+this.ySize-30, 204, 14, 16, 16, achievementText); + this.buttonList.add(this.achievementButton); + for(int i = 0; i < BUTTONS_PER_PAGE; i++){ if(ActuallyAdditionsAPI.BOOKLET_ENTRIES.size() > i){ IBookletEntry entry = ActuallyAdditionsAPI.BOOKLET_ENTRIES.get(i); @@ -107,6 +130,14 @@ public class GuiMainPage extends GuiBooklet{ } } } + else if(button == this.achievementButton){ + GuiScreen achievements = new GuiAAAchievements(this, this.mc.thePlayer.getStatFileWriter()); + this.mc.displayGuiScreen(achievements); + } + else if(button == this.configButton){ + GuiScreen config = new GuiConfiguration(this); + this.mc.displayGuiScreen(config); + } else if(this.showTutorial && button == this.tutorialButton){ if(this.hasBookmarkButtons()){ if(!isShiftKeyDown()){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java index c3b3f06f7..a67ba795f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiPage.java @@ -15,15 +15,21 @@ import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; import de.ellpeck.actuallyadditions.mod.booklet.page.ItemDisplay; +import de.ellpeck.actuallyadditions.mod.inventory.gui.TexturedButton; +import de.ellpeck.actuallyadditions.mod.util.ModUtil; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.awt.*; import java.io.IOException; +import java.net.URI; import java.util.ArrayList; +import java.util.Collections; import java.util.List; @SideOnly(Side.CLIENT) @@ -33,6 +39,8 @@ public class GuiPage extends GuiBooklet{ private final List itemDisplays = new ArrayList(); private int pageTimer; + private GuiButton buttonViewOnline; + public GuiPage(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2){ super(previousScreen, parentPage); @@ -79,11 +87,26 @@ public class GuiPage extends GuiBooklet{ @Override public void actionPerformed(GuiButton button) throws IOException{ - super.actionPerformed(button); + if(button == this.buttonViewOnline){ + List links = this.getWebLinks(); + if(Desktop.isDesktopSupported()){ + for(String link : links){ + try{ + Desktop.getDesktop().browse(new URI(link)); + } + catch(Exception e){ + ModUtil.LOGGER.error("Couldn't open website from Booklet page!", e); + } + } + } + } + else{ + super.actionPerformed(button); - for(IBookletPage page : this.pages){ - if(page != null){ - page.actionPerformed(this, button); + for(IBookletPage page : this.pages){ + if(page != null){ + page.actionPerformed(this, button); + } } } } @@ -93,6 +116,12 @@ public class GuiPage extends GuiBooklet{ this.itemDisplays.clear(); super.initGui(); + List links = this.getWebLinks(); + if(links != null && !links.isEmpty()){ + this.buttonViewOnline = new TexturedButton(RES_LOC_GADGETS, -782822, this.guiLeft+this.xSize-24, this.guiTop+this.ySize-25, 0, 172, 16, 16, Collections.singletonList(TextFormatting.GOLD+"View Online")); + this.buttonList.add(this.buttonViewOnline); + } + for(int i = 0; i < this.pages.length; i++){ IBookletPage page = this.pages[i]; if(page != null){ @@ -101,6 +130,21 @@ public class GuiPage extends GuiBooklet{ } } + private List getWebLinks(){ + List links = new ArrayList(); + + for(IBookletPage page : this.pages){ + if(page != null){ + String link = page.getWebLink(); + if(link != null && !links.contains(link)){ + links.add(link); + } + } + } + + return links; + } + @Override public void updateScreen(){ super.updateScreen(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java index cb23c04f8..03ed10850 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/misc/GuiAAAchievements.java @@ -18,6 +18,9 @@ import net.minecraft.stats.StatisticsManager; import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.lwjgl.input.Keyboard; + +import java.io.IOException; /** * (Partially excerpted from Botania by Vazkii with permission, thanks!) @@ -38,6 +41,20 @@ public class GuiAAAchievements extends GuiAchievements{ @Override public void initGui(){ super.initGui(); - this.buttonList.get(1).displayString = InitAchievements.theAchievementPage.getName(); + + try{ + this.buttonList.remove(1); + } + catch(Exception e){ + ModUtil.LOGGER.error("Something went wrong trying to initialize the Achievements GUI!", e); + } + } + + @Override + protected void keyTyped(char typedChar, int key) throws IOException{ + if(key == Keyboard.KEY_ESCAPE || key == this.mc.gameSettings.keyBindInventory.getKeyCode()){ + this.mc.displayGuiScreen(this.parentScreen); + } + else super.keyTyped(typedChar, key); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java index 6822208f8..e3951a67f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/BookletPage.java @@ -139,6 +139,11 @@ public class BookletPage implements IBookletPage{ return this.chapter.getIdentifier()+"."+this.chapter.getPageIndex(this); } + @Override + public String getWebLink(){ + return "http://ellpeck.de/actaddmanual#"+this.chapter.getIdentifier(); + } + public BookletPage setNoText(){ this.hasNoText = true; return this; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java index 056865841..313878f61 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PageLinkButton.java @@ -49,7 +49,7 @@ public class PageLinkButton extends BookletPage{ Desktop.getDesktop().browse(new URI(this.link)); } catch(Exception e){ - ModUtil.LOGGER.info("Couldn't open website from Link Button page!", e); + ModUtil.LOGGER.error("Couldn't open website from Link Button page!", e); } } } diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guibookletgadgets.png b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guibookletgadgets.png index 6e1af9b4f..bd63be8a6 100644 Binary files a/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guibookletgadgets.png and b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/guibookletgadgets.png differ