From 2b1e20e02c4697ab247e7068baf6445febcfd3e3 Mon Sep 17 00:00:00 2001 From: Progwml6 Date: Sun, 26 Jan 2014 17:05:12 -0500 Subject: [PATCH] guimanual now uses bookdata not hardcoded defaults --- src/mantle/books/BookData.java | 11 +++++++---- src/mantle/client/MProxyClient.java | 7 ++++--- src/mantle/client/gui/GuiManual.java | 15 ++++++++++----- src/mantle/items/Manual.java | 6 ++++++ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/mantle/books/BookData.java b/src/mantle/books/BookData.java index 723c341..4ebc940 100644 --- a/src/mantle/books/BookData.java +++ b/src/mantle/books/BookData.java @@ -1,5 +1,7 @@ package mantle.books; +import mantle.client.block.SmallFontRenderer; + import org.w3c.dom.Document; public class BookData @@ -7,10 +9,11 @@ public class BookData public final String unlocalizedName = new String(); public final String toolTip = new String(); public final String modID = new String(); - public final String LeftImageLocation = new String(); - public final String rightImageLocation = new String(); - public final Document doc = ManualReader.readManual("/assets/mantle/manuals/test.xml"); - + public final String leftImageLocation = new String("textures/gui/bookleft.png"); + public final String rightImageLocation = new String("textures/gui/bookright.png"); + private final Document doc = ManualReader.readManual("/assets/mantle/manuals/test.xml"); + //font can be left null if so, the default from mantle will be used + public SmallFontRenderer font; public Document getDoc () { return this.doc; diff --git a/src/mantle/client/MProxyClient.java b/src/mantle/client/MProxyClient.java index d2af94f..eb6b0fe 100644 --- a/src/mantle/client/MProxyClient.java +++ b/src/mantle/client/MProxyClient.java @@ -1,5 +1,6 @@ package mantle.client; +import mantle.books.BookData; import mantle.books.BookDataStore; import mantle.common.MProxyCommon; @@ -60,13 +61,13 @@ public class MProxyClient extends MProxyCommon if (ID == manualGuiID) { ItemStack stack = player.getCurrentEquippedItem(); - return new GuiManual(stack, MProxyClient.getManualFromStack(stack)); + return new GuiManual(stack, MProxyClient.getBookDataFromStack(stack)); } return null; } - private static Document getManualFromStack (ItemStack stack) + private static BookData getBookDataFromStack (ItemStack stack) { - return BookDataStore.getBookFromName(stack.getItem().getUnlocalizedName()).getDoc(); + return BookDataStore.getBookFromName(stack.getItem().getUnlocalizedName()); } } diff --git a/src/mantle/client/gui/GuiManual.java b/src/mantle/client/gui/GuiManual.java index e46e0df..ec1296e 100644 --- a/src/mantle/client/gui/GuiManual.java +++ b/src/mantle/client/gui/GuiManual.java @@ -12,11 +12,11 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import mantle.books.BookData; import mantle.client.RenderItemCopy; import mantle.client.MProxyClient; import mantle.client.block.SmallFontRenderer; import mantle.client.pages.BookPage; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -34,18 +34,25 @@ public class GuiManual extends GuiScreen private TurnPageButton buttonNextPage; private TurnPageButton buttonPreviousPage; + private static ResourceLocation bookRight;// = new ResourceLocation("mantle", "textures/gui/bookright.png"); + private static ResourceLocation bookLeft;// = new ResourceLocation("mantle", "textures/gui/bookleft.png"); BookPage pageLeft; BookPage pageRight; public SmallFontRenderer fonts = MProxyClient.smallFontRenderer; - public GuiManual(ItemStack stack, Document doc) + public GuiManual(ItemStack stack, BookData data) { this.field_146297_k = Minecraft.getMinecraft(); this.itemstackBook = stack; currentPage = 0; //Stack page - manual = doc; + manual = data.getDoc(); + if (data.font != null) + this.fonts = data.font; + bookLeft = new ResourceLocation(data.modID, data.leftImageLocation); + bookRight = new ResourceLocation(data.modID, data.rightImageLocation); + //renderitem.renderInFrame = true; } @@ -155,8 +162,6 @@ public class GuiManual extends GuiScreen } } - private static final ResourceLocation bookRight = new ResourceLocation("mantle", "textures/gui/bookright.png"); - private static final ResourceLocation bookLeft = new ResourceLocation("mantle", "textures/gui/bookleft.png"); public void drawScreen (int par1, int par2, float par3) { diff --git a/src/mantle/items/Manual.java b/src/mantle/items/Manual.java index 19f7064..55c1cd9 100644 --- a/src/mantle/items/Manual.java +++ b/src/mantle/items/Manual.java @@ -5,6 +5,7 @@ import java.util.List; import mantle.Mantle; import mantle.books.BookDataStore; import mantle.items.abstracts.CraftingItem; +import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -22,6 +23,11 @@ public class Manual extends CraftingItem super(name, textureName, "", "mantle", null); setUnlocalizedName("tconstruct.manual"); } + public Manual(String[] name, String[] textureName, String folder, String modTexturePrefix, CreativeTabs tab) + { + super(name, textureName, "", "mantle", null); + setUnlocalizedName("tconstruct.manual"); + } @Override public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)