mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 23:45:55 +00:00
Refactor how text boxes are handled, move messy stuff to base class.
This commit is contained in:
1 parent
61eb85eb97
commit
f832ae7920
12 files changed
+214
-153
No files matched your search
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -18,6 +19,8 @@ import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
@@ -33,6 +36,7 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
|
||||
protected ToolTipManager ttMan = new ToolTipManager();
|
||||
protected List<IGuiOverlay> overlays = new ArrayList<IGuiOverlay>();
|
||||
protected List<GuiTextField> textFields = Lists.newArrayList();
|
||||
|
||||
protected GuiContainerBase(Container par1Container) {
|
||||
super(par1Container);
|
||||
@@ -44,18 +48,33 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
for (IGuiOverlay overlay : overlays) {
|
||||
overlay.init(this);
|
||||
}
|
||||
|
||||
for (GuiTextField f : textFields) {
|
||||
f.xPosition += getGuiLeft();
|
||||
f.yPosition += getGuiTop();
|
||||
f.setFocused(f == textFields.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
GuiTextField focused = null;
|
||||
for (GuiTextField f : textFields) {
|
||||
if (f.isFocused()) {
|
||||
focused = f;
|
||||
}
|
||||
}
|
||||
if(par2 == 1 || par2 == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
|
||||
//this.mc.thePlayer.closeScreen();
|
||||
if(hideOverlays()) {
|
||||
return;
|
||||
}
|
||||
if (focused == null) {
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
if(focused != null) {
|
||||
focused.textboxKeyTyped(par1, par2);
|
||||
}
|
||||
super.keyTyped(par1, par2);
|
||||
}
|
||||
|
||||
public boolean hideOverlays() {
|
||||
@@ -72,6 +91,15 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
public void addToolTip(GuiToolTip toolTip) {
|
||||
ttMan.addToolTip(toolTip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
|
||||
for (GuiTextField f : textFields) {
|
||||
f.updateCursorCounter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() {
|
||||
@@ -97,6 +125,14 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
}
|
||||
return super.func_146978_c(p_146978_1_, p_146978_2_, p_146978_3_, p_146978_4_, p_146978_5_, p_146978_6_);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int p_73864_3_) {
|
||||
super.mouseClicked(x, y, p_73864_3_);
|
||||
for (GuiTextField f : textFields) {
|
||||
f.mouseClicked(x, y, p_73864_3_);
|
||||
}
|
||||
}
|
||||
|
||||
public void addOverlay(IGuiOverlay overlay) {
|
||||
overlays.add(overlay);
|
||||
@@ -129,6 +165,13 @@ public abstract class GuiContainerBase extends GuiContainer implements ToolTipRe
|
||||
|
||||
ttMan.drawTooltips(this, realMx, realMy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
for (GuiTextField f : textFields) {
|
||||
f.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
|
||||
Reference in new issue
Block a user