More work on the new manual
This commit is contained in:
parent
e01fe31da8
commit
19e66c1c93
15 changed files with 680 additions and 40 deletions
22
src/main/java/techreborn/manual/util/ButtonUtil.java
Normal file
22
src/main/java/techreborn/manual/util/ButtonUtil.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package techreborn.manual.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ButtonUtil
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void addBackButton(int ID, int X, int Y, List buttonList)
|
||||
{
|
||||
buttonList.add(new GuiButtonCustomTexture(ID, X, Y, 50, 60, 17, 12, "button", "", "", 0, 11, 10, 16));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void addNextButton(int ID, int X, int Y, List buttonList)
|
||||
{
|
||||
buttonList.add(new GuiButtonCustomTexture(ID, X, Y, 50, 60, 17, 12, "button", "", "", 0, 1, 10, 17));
|
||||
}
|
||||
}
|
|
@ -1,33 +1,52 @@
|
|||
package techreborn.manual.util;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.client.config.GuiButtonExt;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class GuiButtonCustomTexture extends GuiButtonExt {
|
||||
|
||||
public class GuiButtonCustomTexture extends GuiButtonExt
|
||||
{
|
||||
public int textureU;
|
||||
public int textureV;
|
||||
public ItemStack itemstack;
|
||||
public String texturename;
|
||||
public String LINKED_PAGE;
|
||||
public String NAME;
|
||||
public String imageprefix = "techreborn:textures/manual/elements/";
|
||||
public int buttonHeight;
|
||||
public int buttonWidth;
|
||||
public int buttonU;
|
||||
public int buttonV;
|
||||
public int textureH;
|
||||
public int textureW;
|
||||
|
||||
public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v, int width, int height, ItemStack stack, String linkedPage, String name) {
|
||||
super(id, xPos, yPos, width, height, "_");
|
||||
textureU = u;
|
||||
textureV = v;
|
||||
itemstack = stack;
|
||||
NAME = name;
|
||||
public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v, int buttonWidth, int buttonHeight, String texturename, String linkedPage, String name, int buttonU, int buttonV, int textureH, int textureW)
|
||||
{
|
||||
super(id, xPos, yPos, buttonWidth, buttonHeight, "_");
|
||||
this.textureU = u;
|
||||
this.textureV = v;
|
||||
this.texturename = texturename;
|
||||
this.NAME = name;
|
||||
this.LINKED_PAGE = linkedPage;
|
||||
this.buttonHeight = height;
|
||||
this.buttonWidth = width;
|
||||
this.buttonU = buttonU;
|
||||
this.buttonV = buttonV;
|
||||
this.textureH = textureH;
|
||||
this.textureW = textureW;
|
||||
}
|
||||
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY)
|
||||
{
|
||||
if (this.visible)
|
||||
{
|
||||
boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
|
@ -35,7 +54,8 @@ public class GuiButtonCustomTexture extends GuiButtonExt {
|
|||
int u = textureU;
|
||||
int v = textureV;
|
||||
|
||||
if (flag) {
|
||||
if (flag)
|
||||
{
|
||||
u += width;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(0f, 0f, 0f, 1f);
|
||||
|
@ -46,14 +66,25 @@ public class GuiButtonCustomTexture extends GuiButtonExt {
|
|||
GL11.glEnable(32826);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemIntoGUI(itemstack, this.xPosition, this.yPosition);
|
||||
renderImage(this.xPosition, this.yPosition);
|
||||
this.drawString(mc.fontRendererObj, this.NAME, this.xPosition + 20, this.yPosition + 3, Color.white.getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
public void renderImage(int offsetX, int offsetY)
|
||||
{
|
||||
TextureManager render = Minecraft.getMinecraft().renderEngine;
|
||||
render.bindTexture(new ResourceLocation(imageprefix + this.texturename + ".png"));
|
||||
|
||||
public boolean getIsHovering() {
|
||||
return hovered;
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
drawTexturedModalRect(offsetX, offsetY, this.buttonU, this.buttonV, this.textureW, this.textureH);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
public boolean getIsHovering()
|
||||
{
|
||||
return hovered;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
package techreborn.manual.util;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.client.config.GuiButtonExt;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class GuiButtonItemTexture extends GuiButtonExt {
|
||||
|
||||
public int textureU;
|
||||
public int textureV;
|
||||
public ItemStack itemstack;
|
||||
public String LINKED_PAGE;
|
||||
public String NAME;
|
||||
|
||||
public GuiButtonItemTexture(int id, int xPos, int yPos, int u, int v, int width, int height, ItemStack stack, String linkedPage, String name) {
|
||||
super(id, xPos, yPos, width, height, "_");
|
||||
textureU = u;
|
||||
textureV = v;
|
||||
itemstack = stack;
|
||||
NAME = name;
|
||||
this.LINKED_PAGE = linkedPage;
|
||||
}
|
||||
|
||||
public void drawButton(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
boolean flag = mouseX >= this.xPosition && mouseY >= this.yPosition
|
||||
&& mouseX < this.xPosition + this.width
|
||||
&& mouseY < this.yPosition + this.height;
|
||||
mc.getTextureManager().bindTexture(buttonTextures);
|
||||
int u = textureU;
|
||||
int v = textureV;
|
||||
|
||||
if (flag) {
|
||||
u += width;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(0f, 0f, 0f, 1f);
|
||||
this.drawTexturedModalRect(this.xPosition, this.yPosition, u, v, width, height);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glEnable(32826);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemIntoGUI(itemstack, this.xPosition, this.yPosition);
|
||||
this.drawString(mc.fontRendererObj, this.NAME, this.xPosition + 20, this.yPosition + 3, Color.white.getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsHovering() {
|
||||
return hovered;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue