Some GUI work. Some things will be broke.
This commit is contained in:
parent
2f9d29d703
commit
cc39e5f07a
|
@ -3,40 +3,29 @@ package com.pahimar.ee3.client.gui.inventory;
|
|||
import com.pahimar.ee3.inventory.ContainerAlchemicalTome;
|
||||
import com.pahimar.ee3.reference.Textures;
|
||||
import com.pahimar.repackage.cofh.lib.gui.GuiBase;
|
||||
import com.pahimar.repackage.cofh.lib.gui.element.ElementButton;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.InventoryBasic;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiAlchemicalTome extends GuiBase
|
||||
{
|
||||
// private InventoryAlchemicalTome inventoryAlchemicalTome;
|
||||
private InventoryPlayer inventoryPlayer;
|
||||
public static InventoryBasic tempInventory = new InventoryBasic("tmp", true, 81);
|
||||
|
||||
private float currentScroll;
|
||||
private boolean isScrolling;
|
||||
private boolean wasClicking;
|
||||
private GuiTextField searchField;
|
||||
|
||||
private Slot field_147064_C;
|
||||
private boolean field_147057_D;
|
||||
private ElementButton prevPageButton;
|
||||
private ElementButton nextPageButton;
|
||||
|
||||
public GuiAlchemicalTome(EntityPlayer entityPlayer)
|
||||
{
|
||||
super(new ContainerAlchemicalTome(entityPlayer.inventory));
|
||||
super(new ContainerAlchemicalTome(entityPlayer.inventory), Textures.Gui.ALCHEMICAL_TOME);
|
||||
this.inventoryPlayer = entityPlayer.inventory;
|
||||
entityPlayer.openContainer = this.inventorySlots;
|
||||
this.allowUserInput = true;
|
||||
xSize = 209;
|
||||
xSize = 256;
|
||||
ySize = 200;
|
||||
}
|
||||
|
||||
|
@ -44,157 +33,30 @@ public class GuiAlchemicalTome extends GuiBase
|
|||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
this.searchField = new GuiTextField(this.fontRendererObj, this.guiLeft + 90, this.guiTop + 19, 96, this.fontRendererObj.FONT_HEIGHT);
|
||||
this.searchField.setMaxStringLength(32);
|
||||
this.searchField.setEnableBackgroundDrawing(false);
|
||||
this.searchField.setVisible(true);
|
||||
this.searchField.setFocused(true);
|
||||
this.searchField.setCanLoseFocus(false);
|
||||
this.searchField.setText("");
|
||||
this.searchField.setTextColor(16777215);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
Keyboard.enableRepeatEvents(false);
|
||||
}
|
||||
|
||||
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_)
|
||||
{
|
||||
boolean flag = Mouse.isButtonDown(0);
|
||||
int k = this.guiLeft;
|
||||
int l = this.guiTop;
|
||||
int i1 = k + 175;
|
||||
int j1 = l + 18;
|
||||
int k1 = i1 + 14;
|
||||
int l1 = j1 + 112;
|
||||
|
||||
if (!this.wasClicking && flag && p_73863_1_ >= i1 && p_73863_2_ >= j1 && p_73863_1_ < k1 && p_73863_2_ < l1)
|
||||
{
|
||||
this.isScrolling = this.needsScrollBars();
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
this.isScrolling = false;
|
||||
}
|
||||
|
||||
this.wasClicking = flag;
|
||||
|
||||
if (this.isScrolling)
|
||||
{
|
||||
this.currentScroll = ((float) (p_73863_2_ - j1) - 7.5F) / ((float) (l1 - j1) - 15.0F);
|
||||
|
||||
if (this.currentScroll < 0.0F)
|
||||
{
|
||||
this.currentScroll = 0.0F;
|
||||
}
|
||||
|
||||
if (this.currentScroll > 1.0F)
|
||||
{
|
||||
this.currentScroll = 1.0F;
|
||||
}
|
||||
|
||||
((ContainerAlchemicalTome) this.inventorySlots).scrollTo(this.currentScroll);
|
||||
}
|
||||
|
||||
super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
prevPageButton = new ElementButton(this, 10, 10, "Prev", 0, 0, 20, 0, 0, 0, 20, 10, 40, 10, "textures/gui/elements/arrowLeft.png");
|
||||
s
|
||||
addElement(prevPageButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
String containerName = StatCollector.translateToLocal(inventoryPlayer.getInventoryName());
|
||||
fontRendererObj.drawString(containerName, xSize / 2 - fontRendererObj.getStringWidth(containerName) / 2, 6, 4210752);
|
||||
fontRendererObj.drawString("Search Items", 16, 20, 4210752);
|
||||
// NOOP
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3)
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int x, int y)
|
||||
{
|
||||
mouseX = x - guiLeft;
|
||||
mouseY = y - guiTop;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(Textures.Gui.ALCHEMICAL_TOME);
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
||||
this.searchField.drawTextBox();
|
||||
}
|
||||
|
||||
protected void keyTyped(char p_73869_1_, int p_73869_2_)
|
||||
{
|
||||
if (this.field_147057_D)
|
||||
{
|
||||
this.field_147057_D = false;
|
||||
this.searchField.setText("");
|
||||
}
|
||||
|
||||
if (!this.checkHotbarKeys(p_73869_2_))
|
||||
{
|
||||
if (this.searchField.textboxKeyTyped(p_73869_1_, p_73869_2_))
|
||||
{
|
||||
this.updateSearch();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped(p_73869_1_, p_73869_2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSearch()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void updateFilteredItems(ContainerAlchemicalTome containerAlchemicalTome)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput()
|
||||
{
|
||||
super.handleMouseInput();
|
||||
int i = Mouse.getEventDWheel();
|
||||
|
||||
if (i != 0 && this.needsScrollBars())
|
||||
{
|
||||
int j = ((ContainerAlchemicalTome) this.inventorySlots).itemList.size() / 9 - 5 + 1;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
i = -1;
|
||||
}
|
||||
|
||||
this.currentScroll = (float) ((double) this.currentScroll - (double) i / (double) j);
|
||||
|
||||
if (this.currentScroll < 0.0F)
|
||||
{
|
||||
this.currentScroll = 0.0F;
|
||||
}
|
||||
|
||||
if (this.currentScroll > 1.0F)
|
||||
{
|
||||
this.currentScroll = 1.0F;
|
||||
}
|
||||
|
||||
((ContainerAlchemicalTome) this.inventorySlots).scrollTo(this.currentScroll);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean needsScrollBars()
|
||||
{
|
||||
return ((ContainerAlchemicalTome) this.inventorySlots).isScrollable();
|
||||
bindTexture(texture);
|
||||
drawSizedTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize, 256f, 256f);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef(guiLeft, guiTop, 0.0F);
|
||||
drawElements(partialTicks, false);
|
||||
drawTabs(partialTicks, false);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,14 @@ public abstract class ElementBase {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ElementBase setTexture(ResourceLocation texture, int texW, int texH) {
|
||||
|
||||
this.texture = texture;
|
||||
this.texW = texW;
|
||||
this.texH = texH;
|
||||
return this;
|
||||
}
|
||||
|
||||
public final ElementBase setVisible(boolean visible) {
|
||||
|
||||
this.visible = visible;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.pahimar.repackage.cofh.lib.gui.element;
|
||||
|
||||
import com.pahimar.ee3.util.ResourceLocationHelper;
|
||||
import com.pahimar.repackage.cofh.lib.gui.GuiBase;
|
||||
import com.pahimar.repackage.cofh.lib.render.RenderHelper;
|
||||
import com.pahimar.repackage.cofh.lib.util.helpers.StringHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,7 +20,18 @@ public class ElementButton extends ElementBase {
|
|||
String tooltip;
|
||||
|
||||
public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, String texture) {
|
||||
this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, sizeX, sizeY, 256, 256, texture);
|
||||
}
|
||||
|
||||
public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, ResourceLocation texture) {
|
||||
this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, sizeX, sizeY, 256, 256, texture);
|
||||
}
|
||||
|
||||
public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, int texW, int texH, String texture) {
|
||||
this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, sizeX, sizeY, texW, texH, ResourceLocationHelper.getResourceLocation(texture));
|
||||
}
|
||||
|
||||
public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, int texW, int texH, ResourceLocation texture) {
|
||||
super(gui, posX, posY);
|
||||
setName(name);
|
||||
setSize(sizeX, sizeY);
|
||||
|
@ -29,9 +42,11 @@ public class ElementButton extends ElementBase {
|
|||
this.hoverY = hoverY;
|
||||
}
|
||||
|
||||
public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX,
|
||||
int sizeY, String texture) {
|
||||
public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX, int sizeY, int texW, int texH, String texture) {
|
||||
this(gui, posX, posY, name, sheetX, sheetY, hoverX, hoverY, disabledX, disabledY, sizeX, sizeY, texW, texH, ResourceLocationHelper.getResourceLocation(texture));
|
||||
}
|
||||
|
||||
public ElementButton(GuiBase gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int disabledX, int disabledY, int sizeX, int sizeY, int texW, int texH, ResourceLocation texture) {
|
||||
super(gui, posX, posY);
|
||||
setName(name);
|
||||
setSize(sizeX, sizeY);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 256 B |
Binary file not shown.
Before Width: | Height: | Size: 472 B |
Binary file not shown.
Before Width: | Height: | Size: 217 B After Width: | Height: | Size: 272 B |
Binary file not shown.
Before Width: | Height: | Size: 228 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue