Added back config, achievements and view online button

This commit is contained in:
Ellpeck 2016-11-17 17:36:00 +01:00
parent 95ca15cd1a
commit c8f4c94c94
7 changed files with 106 additions and 7 deletions

View file

@ -59,6 +59,8 @@ public interface IBookletPage{
String getIdentifier();
String getWebLink();
IBookletPage addTextReplacement(String key, String value);
IBookletPage addTextReplacement(String key, float value);

View file

@ -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 Ive 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<String> configText = new ArrayList<String>();
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<String> achievementText = new ArrayList<String>();
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()){

View file

@ -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<ItemDisplay> itemDisplays = new ArrayList<ItemDisplay>();
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<String> 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<String> 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<String> getWebLinks(){
List<String> links = new ArrayList<String>();
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();

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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);
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB