ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/page/PagePicture.java

51 lines
1.9 KiB
Java
Raw Normal View History

/*
2016-05-16 22:52:27 +02:00
* This file ("PagePicture.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.booklet.page;
2016-01-05 14:57:50 +01:00
import de.ellpeck.actuallyadditions.api.internal.IBookletGui;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
2016-01-05 14:57:50 +01:00
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
2016-01-07 18:20:59 +01:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class PagePicture extends PageTextOnly{
2016-05-19 20:05:12 +02:00
private final ResourceLocation resLoc;
private final int textStartY;
public PagePicture(int id, String resLocName, int textStartY){
this(id, AssetUtil.getBookletGuiLocation(resLocName), textStartY);
}
public PagePicture(int id, ResourceLocation resLoc, int textStartY){
super(id);
this.textStartY = textStartY;
this.resLoc = resLoc;
}
@Override
@SideOnly(Side.CLIENT)
2016-01-05 14:57:50 +01:00
public void renderPre(IBookletGui gui, int mouseX, int mouseY, int ticksElapsed, boolean mousePressed){
GlStateManager.enableBlend();
2016-01-05 14:57:50 +01:00
Minecraft.getMinecraft().getTextureManager().bindTexture(this.resLoc);
gui.drawRect(gui.getGuiLeft(), gui.getGuiTop(), 0, 0, gui.getXSize(), gui.getYSize());
GlStateManager.disableBlend();
2016-05-14 13:51:18 +02:00
String text = gui.getCurrentEntrySet().getCurrentPage().getText();
if(text != null && !text.isEmpty()){
2016-05-02 17:46:53 +02:00
StringUtil.drawSplitString(Minecraft.getMinecraft().fontRendererObj, text, gui.getGuiLeft()+14, gui.getGuiTop()+this.textStartY, 115, 0, false);
}
}
}