More fancy gui stuff (WIP)

This commit is contained in:
gigabit101 2015-08-16 23:59:47 +01:00
parent 323725be11
commit 7a50db2d61
4 changed files with 57 additions and 1 deletions

View file

@ -2,8 +2,12 @@ package techreborn.pda.pages;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.lib.ModInfo;
import techreborn.pda.PageCollection;
import techreborn.pda.util.GuiButtonCustomTexture;
import techreborn.pda.util.GuiButtonTextOnly;
public class ContentsPage extends TitledPage{
@ -19,6 +23,7 @@ public class ContentsPage extends TitledPage{
buttonList.add(new GuiButton(0, getXMin() + 25, getYMin() + 20, "ITEMS"));
buttonList.add(new GuiButton(1, getXMin() + 25, getYMin() + 40, "BLOCKS"));
buttonList.add(new GuiButton(2, getXMin() + 25, getYMin() + 160, "INDEX"));
buttonList.add(new GuiButtonCustomTexture(3, getXMin() + 25, getYMin() + 60, 0, 46, 60, 20, new ItemStack(ModBlocks.Aesu), "INDEX"));
}
@Override

View file

@ -2,8 +2,11 @@ package techreborn.pda.pages;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.item.ItemStack;
import techreborn.init.ModItems;
import techreborn.pda.PageCollection;
import techreborn.pda.util.GuiButtonAHeight;
import techreborn.pda.util.GuiButtonCustomTexture;
import techreborn.pda.util.GuiButtonTextOnly;
public class ItemsPage extends TitledPage{
@ -15,7 +18,7 @@ public class ItemsPage extends TitledPage{
@SuppressWarnings("unchecked")
@Override
public void initGui() {
// buttonList.clear();
buttonList.clear();
int row = 0;
int collum = 0;
for (BasePage page : collection.pages){

View file

@ -23,6 +23,7 @@ public class GuiButtonAHeight extends GuiButton{
int k = this.getHoverState(this.field_146123_n);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height);

View file

@ -0,0 +1,47 @@
package techreborn.pda.util;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.config.GuiButtonExt;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class GuiButtonCustomTexture extends GuiButtonExt {
public int textureU;
public int textureV;
public ItemStack itemstack;
public String LINKED_PAGE;
public GuiButtonCustomTexture(int id, int xPos, int yPos, int u, int v, int width, int height, ItemStack stack, String linkedPage) {
super(id, xPos, yPos, width, height, "_");
textureU = u;
textureV = v;
itemstack = stack;
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();
}
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, itemstack, this.xPosition, this.yPosition);
this.drawString(mc.fontRenderer, itemstack.getDisplayName(), this.xPosition + 20, this.yPosition + 3, 515611);
}
}
}