diff options
author | Kiwi <42833050+Kiwi233@users.noreply.github.com> | 2020-05-24 08:28:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-24 08:28:19 +0800 |
commit | f0bce85d3faf040d87a22d83250ae2d9767c3642 (patch) | |
tree | ed60c1d975c8b06a27cae03d148714f7bb9e9805 /src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java | |
parent | ac7282a30ef161101cabc921e52db5c5d7e0096c (diff) | |
parent | d6c19a9b6434c8a4c59ea8452603f85cfd2ad208 (diff) | |
download | GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.gz GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.tar.bz2 GT5-Unofficial-f0bce85d3faf040d87a22d83250ae2d9767c3642.zip |
Merge pull request #1 from GTNewHorizons/experimental
5/24
Diffstat (limited to 'src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java')
-rw-r--r-- | src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java new file mode 100644 index 0000000000..db7029d60f --- /dev/null +++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java @@ -0,0 +1,64 @@ +package gregtech.api.gui.widgets; + +import gregtech.api.interfaces.IGuiScreen; +import net.minecraft.client.Minecraft; +import net.minecraft.item.ItemStack; +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class GT_GuiFakeItemButton implements IGuiScreen.IGuiElement { + + private final GT_GuiIcon bgIcon; + private ItemStack item; + private IGuiScreen gui; + private int x0, y0, xPosition, yPosition; + private int width, height; + + public GT_GuiFakeItemButton(IGuiScreen gui, int x, int y, GT_GuiIcon bgIcon) { + this.gui = gui; + this.x0 = x; + this.y0 = y; + this.bgIcon = bgIcon; + item = null; + width = 18; + height = 18; + gui.addElement(this); + } + + public GT_GuiFakeItemButton setItem(ItemStack i) { + item = i; + return this; + } + + public ItemStack getItem(){ + return item; + } + + @Override + public void onInit() { + xPosition = x0 + gui.getGuiLeft(); + yPosition = y0 + gui.getGuiTop(); + } + + @Override + public void draw(int mouseX, int mouseY, float parTicks) { + GL11.glColor4f(1, 1, 1, 1); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + if (bgIcon != null){ + GT_GuiIcon.render(bgIcon, xPosition-1, yPosition-1, 18, 18,0,true); + } + + if (item != null) + gui.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer(), Minecraft.getMinecraft().getTextureManager(), item, xPosition, yPosition); + + GL11.glPopAttrib(); + } + + public Rectangle getBounds() { + return new Rectangle(x0, y0, width, height); + } +} |