mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-21 12:32:42 +00:00
books can now be translated if bookdata says so
This commit is contained in:
1 parent
2b1e20e02c
commit
631995a450
13 files changed
+71
-24
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package mantle.books;
|
||||
|
||||
import mantle.client.block.SmallFontRenderer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
@@ -9,11 +10,13 @@ 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("textures/gui/bookleft.png");
|
||||
public final String rightImageLocation = new String("textures/gui/bookright.png");
|
||||
public final ResourceLocation leftImage = new ResourceLocation("mantle", "textures/gui/bookleft.png");
|
||||
public final ResourceLocation rightImage = new ResourceLocation("mantle", "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 final Boolean isTranslatable = false;
|
||||
|
||||
public Document getDoc ()
|
||||
{
|
||||
return this.doc;
|
||||
|
||||
@@ -31,6 +31,7 @@ public class GuiManual extends GuiScreen
|
||||
int bookTotalPages = 1;
|
||||
int currentPage;
|
||||
int maxPages;
|
||||
BookData bData;
|
||||
|
||||
private TurnPageButton buttonNextPage;
|
||||
private TurnPageButton buttonPreviousPage;
|
||||
@@ -50,8 +51,9 @@ public class GuiManual extends GuiScreen
|
||||
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);
|
||||
bookLeft = data.leftImage;
|
||||
bookRight = data.rightImage;
|
||||
this.bData = data;
|
||||
|
||||
//renderitem.renderInFrame = true;
|
||||
}
|
||||
@@ -73,8 +75,8 @@ public class GuiManual extends GuiScreen
|
||||
updateText();
|
||||
int xPos = (this.field_146294_l) / 2; //TODO Width?
|
||||
//TODO buttonList
|
||||
this.field_146292_n.add(this.buttonNextPage = new TurnPageButton(1, xPos + bookImageWidth - 50, 180, true));
|
||||
this.field_146292_n.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - bookImageWidth + 24, 180, false));
|
||||
this.field_146292_n.add(this.buttonNextPage = new TurnPageButton(1, xPos + bookImageWidth - 50, 180, true, bData));
|
||||
this.field_146292_n.add(this.buttonPreviousPage = new TurnPageButton(2, xPos - bookImageWidth + 24, 180, false, bData));
|
||||
}
|
||||
|
||||
protected void actionPerformed (GuiButton button)
|
||||
@@ -184,9 +186,9 @@ public class GuiManual extends GuiScreen
|
||||
pageRight.renderBackgroundLayer(localWidth + 220, localHeight + 12);
|
||||
|
||||
if (pageLeft != null)
|
||||
pageLeft.renderContentLayer(localWidth + 16, localHeight + 12);
|
||||
pageLeft.renderContentLayer(localWidth + 16, localHeight + 12, bData.isTranslatable);
|
||||
if (pageRight != null)
|
||||
pageRight.renderContentLayer(localWidth + 220, localHeight + 12);
|
||||
pageRight.renderContentLayer(localWidth + 220, localHeight + 12, bData.isTranslatable);
|
||||
}
|
||||
|
||||
public Minecraft getMC ()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mantle.client.gui;
|
||||
|
||||
import mantle.books.BookData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -16,14 +17,16 @@ public class TurnPageButton extends GuiButton
|
||||
* True for pointing right (next page), false for pointing left (previous page).
|
||||
*/
|
||||
private final boolean nextPage;
|
||||
private static ResourceLocation background;// = new ResourceLocation("tinker", "textures/gui/bookleft.png");
|
||||
|
||||
public TurnPageButton(int par1, int par2, int par3, boolean par4)
|
||||
|
||||
public TurnPageButton(int par1, int par2, int par3, boolean par4, BookData data)
|
||||
{
|
||||
super(par1, par2, par3, 23, 13, "");
|
||||
this.nextPage = par4;
|
||||
background = data.leftImage;
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookleft.png");
|
||||
|
||||
/**
|
||||
* Draws this button to the screen.
|
||||
|
||||
@@ -11,7 +11,7 @@ public class BlankPage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localwidth, int localheight)
|
||||
public void renderContentLayer (int localwidth, int localheight, boolean isTranslatable)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,5 +21,5 @@ public abstract class BookPage
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void renderContentLayer (int localwidth, int localheight);
|
||||
public abstract void renderContentLayer (int localwidth, int localheight, boolean isTranslatable);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package mantle.client.pages;
|
||||
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
@@ -35,10 +36,14 @@ public class ContentsTablePage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
if (isTranslatable)
|
||||
text = StatCollector.translateToLocal(text);
|
||||
manual.fonts.drawString("\u00a7n" + text, localWidth + 25 + manual.fonts.getStringWidth(text) / 2, localHeight + 4, 0);
|
||||
}
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
manual.renderitem.zLevel = 100;
|
||||
@@ -46,6 +51,9 @@ public class ContentsTablePage extends BookPage
|
||||
{
|
||||
manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 16, localHeight + 18 * i + 18);
|
||||
int yOffset = 18;
|
||||
if (isTranslatable)
|
||||
iconText[i] = StatCollector.translateToLocal(iconText[i]);
|
||||
|
||||
if (iconText[i].length() > 40)
|
||||
yOffset = 13;
|
||||
manual.fonts.drawString(iconText[i], localWidth + 38, localHeight + 18 * i + yOffset, 0);
|
||||
|
||||
@@ -3,6 +3,7 @@ package mantle.client.pages;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
@@ -34,8 +35,10 @@ public class CraftingPage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
|
||||
{
|
||||
if (isTranslatable)
|
||||
text = StatCollector.translateToLocal(text);
|
||||
if (size.equals("two"))
|
||||
drawCraftingPage(text, icons, 2, localWidth, localHeight + 12);
|
||||
if (size.equals("three"))
|
||||
@@ -91,7 +94,7 @@ public class CraftingPage extends BookPage
|
||||
drawBackground(3, localwidth + (side != 1 ? 6 : 0), localheight + 12);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookcrafting.png");
|
||||
private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookcrafting.png");
|
||||
|
||||
public void drawBackground (int size, int localWidth, int localHeight)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package mantle.client.pages;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
@@ -29,11 +30,13 @@ public class FurnacePage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
|
||||
{
|
||||
if (text != null)
|
||||
if (text != null){
|
||||
if(isTranslatable)
|
||||
text = StatCollector.translateToLocal(text);
|
||||
manual.fonts.drawString("\u00a7n" + text, localWidth + 50, localHeight + 4, 0);
|
||||
|
||||
}
|
||||
GL11.glScalef(2f, 2f, 2f);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
@@ -52,7 +55,7 @@ public class FurnacePage extends BookPage
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
|
||||
private static final ResourceLocation background = new ResourceLocation("tinker", "textures/gui/bookfurnace.png");
|
||||
private static final ResourceLocation background = new ResourceLocation("mantle", "textures/gui/bookfurnace.png");
|
||||
|
||||
public void renderBackgroundLayer (int localWidth, int localHeight)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mantle.client.pages;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
@@ -25,8 +26,10 @@ public class PicturePage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
|
||||
{
|
||||
if(isTranslatable)
|
||||
text = StatCollector.translateToLocal(text);
|
||||
manual.fonts.drawSplitString(text, localWidth + 8, localHeight, 178, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package mantle.client.pages;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
@@ -21,8 +23,13 @@ public class SectionPage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
|
||||
{
|
||||
if (isTranslatable)
|
||||
{
|
||||
title = StatCollector.translateToLocal(title);
|
||||
body = StatCollector.translateToLocal(body);
|
||||
}
|
||||
manual.fonts.drawSplitString("\u00a7n" + title, localWidth + 70, localHeight + 4, 178, 0);
|
||||
manual.fonts.drawSplitString(body, localWidth, localHeight + 16, 190, 0);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package mantle.client.pages;
|
||||
import mantle.lib.client.MantleClientRegistry;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
@@ -34,8 +35,11 @@ public class SidebarPage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
|
||||
{
|
||||
if(isTranslatable){
|
||||
text = StatCollector.translateToLocal(text);
|
||||
}
|
||||
manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
@@ -43,6 +47,9 @@ public class SidebarPage extends BookPage
|
||||
int offset = text.length() / 4 + 10;
|
||||
for (int i = 0; i < icons.length; i++)
|
||||
{
|
||||
if(isTranslatable){
|
||||
iconText[i]= StatCollector.translateToLocal(iconText[i]);
|
||||
}
|
||||
manual.renderitem.renderItemIntoGUI(manual.fonts, manual.getMC().renderEngine, icons[i], localWidth + 8, localHeight + 18 * i + offset);
|
||||
int yOffset = 39;
|
||||
if (iconText[i].length() > 40)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package mantle.client.pages;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
@@ -16,8 +18,10 @@ public class TextPage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean IsTranslatable)
|
||||
{
|
||||
if(IsTranslatable)
|
||||
text = StatCollector.translateToLocal(text);
|
||||
manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package mantle.client.pages;
|
||||
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
@@ -16,8 +18,10 @@ public class TitlePage extends BookPage
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderContentLayer (int localWidth, int localHeight)
|
||||
public void renderContentLayer (int localWidth, int localHeight, boolean isTranslatable)
|
||||
{
|
||||
if (isTranslatable)
|
||||
text = StatCollector.translateToLocal(text);
|
||||
manual.fonts.drawSplitString(text, localWidth, localHeight, 178, 0);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user