mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 15:33:06 +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
@@ -1,5 +1,7 @@
|
||||
package crazypants.enderio.machine.buffer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
@@ -27,25 +29,26 @@ public class GuiBuffer extends GuiPoweredMachineBase<TileBuffer> {
|
||||
super(te, new ContainerBuffer(par1InventoryPlayer, te));
|
||||
redstoneButton.setPosition(isFull() ? 153 : 120, 24);
|
||||
configB.setPosition(isFull() ? 153 : 120, 42);
|
||||
|
||||
FontRenderer fnt = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
if(te.hasPower()) {
|
||||
int x = (isFull() ? 20 : 58);
|
||||
int y = guiTop + 27;
|
||||
|
||||
maxInput = new GuiTextField(getFontRenderer(), x, y, 60, 12);
|
||||
y += 28;
|
||||
maxOutput = new GuiTextField(getFontRenderer(), x, y, 60, 12);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
|
||||
int x = guiLeft + (isFull() ? 20 : 58);
|
||||
int y = guiTop + 27;
|
||||
maxInput = new GuiTextField(getFontRenderer(), x, y, 60, 12);
|
||||
maxInput.setCanLoseFocus(true);
|
||||
maxInput.setMaxStringLength(10);
|
||||
maxInput.setFocused(false);
|
||||
maxInput.setText(PowerDisplayUtil.formatPower(getTileEntity().getMaxInput()));
|
||||
|
||||
y += 28;
|
||||
maxOutput = new GuiTextField(getFontRenderer(), x, y, 60, 12);
|
||||
maxOutput.setCanLoseFocus(true);
|
||||
maxOutput.setMaxStringLength(10);
|
||||
maxOutput.setFocused(getTileEntity().hasPower());
|
||||
maxOutput.setText(PowerDisplayUtil.formatPower(getTileEntity().getMaxOutput()));
|
||||
}
|
||||
|
||||
@@ -57,8 +60,6 @@ public class GuiBuffer extends GuiPoweredMachineBase<TileBuffer> {
|
||||
}
|
||||
|
||||
if(getTileEntity().hasPower()) {
|
||||
maxInput.textboxKeyTyped(par1, par2);
|
||||
maxOutput.textboxKeyTyped(par1, par2);
|
||||
updateInputOutput();
|
||||
}
|
||||
}
|
||||
@@ -90,23 +91,6 @@ public class GuiBuffer extends GuiPoweredMachineBase<TileBuffer> {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketBufferIO(getTileEntity(), lastInput, lastOutput));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
if(getTileEntity().hasPower()) {
|
||||
maxInput.mouseClicked(par1, par2, par3);
|
||||
maxOutput.mouseClicked(par1, par2, par3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
if(getTileEntity().hasPower()) {
|
||||
maxInput.updateCursorCounter();
|
||||
maxOutput.updateCursorCounter();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean showRecipeButton() {
|
||||
return false;
|
||||
@@ -144,6 +128,8 @@ public class GuiBuffer extends GuiPoweredMachineBase<TileBuffer> {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
RenderUtil.bindTexture(isFull() ? TEXTURE_FULL : TEXTURE_SIMPLE);
|
||||
@@ -173,9 +159,6 @@ public class GuiBuffer extends GuiPoweredMachineBase<TileBuffer> {
|
||||
|
||||
getFontRenderer().drawStringWithShadow(Lang.localize("gui.simple.in"), sx, sy, 0xFFFFFF);
|
||||
getFontRenderer().drawStringWithShadow(Lang.localize("gui.simple.out"), sx, sy + 27, 0xFFFFFF);
|
||||
|
||||
maxInput.drawTextBox();
|
||||
maxOutput.drawTextBox();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -169,6 +169,22 @@ public class GuiCapBank extends GuiContainerBase {
|
||||
|
||||
y += 20;
|
||||
configB = new GuiButtonIoConfig(this, CONFIG_ID, x, y, te, configOverlay);
|
||||
|
||||
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
x = inputX;
|
||||
y = inputY;
|
||||
maxInputTF = new GuiTextField(fontRenderer, x, y, 68, 16);
|
||||
maxInputTF.setCanLoseFocus(true);
|
||||
maxInputTF.setMaxStringLength(10);
|
||||
maxInputTF.setFocused(false);
|
||||
|
||||
x = outputX;
|
||||
y = outputY;
|
||||
maxOutputTF = new GuiTextField(fontRenderer, x, y, 68, 16);
|
||||
maxOutputTF.setCanLoseFocus(true);
|
||||
maxOutputTF.setMaxStringLength(10);
|
||||
maxOutputTF.setFocused(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,24 +193,8 @@ public class GuiCapBank extends GuiContainerBase {
|
||||
|
||||
configB.onGuiInit();
|
||||
|
||||
FontRenderer fontRenderer = getFontRenderer();
|
||||
|
||||
inputRsButton.onGuiInit();
|
||||
outputRsButton.onGuiInit();
|
||||
|
||||
int x = guiLeft + inputX;
|
||||
int y = guiTop + inputY;
|
||||
maxInputTF = new GuiTextField(fontRenderer, x, y, 68, 16);
|
||||
maxInputTF.setCanLoseFocus(true);
|
||||
maxInputTF.setMaxStringLength(10);
|
||||
maxInputTF.setFocused(false);
|
||||
|
||||
x = guiLeft + outputX;
|
||||
y = guiTop + outputY;
|
||||
maxOutputTF = new GuiTextField(fontRenderer, x, y, 68, 16);
|
||||
maxOutputTF.setCanLoseFocus(true);
|
||||
maxOutputTF.setMaxStringLength(10);
|
||||
maxOutputTF.setFocused(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,8 +203,6 @@ public class GuiCapBank extends GuiContainerBase {
|
||||
if(par1 == 'e') {
|
||||
super.keyTyped(par1, 1);
|
||||
}
|
||||
maxInputTF.textboxKeyTyped(par1, par2);
|
||||
maxOutputTF.textboxKeyTyped(par1, par2);
|
||||
updateInputOutput();
|
||||
}
|
||||
|
||||
@@ -241,22 +239,10 @@ public class GuiCapBank extends GuiContainerBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
maxInputTF.mouseClicked(par1, par2, par3);
|
||||
maxOutputTF.mouseClicked(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
maxInputTF.updateCursorCounter();
|
||||
maxOutputTF.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
requestStateUpdate();
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
@@ -274,9 +260,6 @@ public class GuiCapBank extends GuiContainerBase {
|
||||
guibutton.drawButton(mc, 0, 0);
|
||||
}
|
||||
|
||||
maxInputTF.drawTextBox();
|
||||
maxOutputTF.drawTextBox();
|
||||
|
||||
int midX = sx + xSize / 2;
|
||||
|
||||
String str = Lang.localize("gui.capBank.maxIo") + " " + PowerDisplayUtil.formatPower(network.getMaxIO()) +
|
||||
|
||||
@@ -84,6 +84,8 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends Gu
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
super.drawGuiContainerBackgroundLayer(par1, par2, par3);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
for (int i = 0; i < buttonList.size(); ++i) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
|
||||
import crazypants.util.PlayerUtil;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
@@ -29,6 +28,7 @@ import crazypants.render.ColorUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.util.PlayerUtil;
|
||||
|
||||
public class GuiHyperCube extends GuiContainerBase {
|
||||
|
||||
@@ -165,6 +165,12 @@ public class GuiHyperCube extends GuiContainerBase {
|
||||
publicChannelList.addSelectionListener(selectionListener);
|
||||
privateChannelList.addSelectionListener(selectionListener);
|
||||
|
||||
y = 12;
|
||||
x = 8;
|
||||
newChannelTF = new GuiTextField(Minecraft.getMinecraft().fontRenderer, x, y, 103, 16);
|
||||
newChannelTF.setCanLoseFocus(false);
|
||||
newChannelTF.setMaxStringLength(32);
|
||||
newChannelTF.setFocused(true);
|
||||
}
|
||||
|
||||
private void updateIoButtons() {
|
||||
@@ -213,16 +219,6 @@ public class GuiHyperCube extends GuiContainerBase {
|
||||
|
||||
buttonList.clear();
|
||||
|
||||
int x = guiLeft + 203;
|
||||
int y = guiTop + 12;
|
||||
|
||||
y = guiTop + 12;
|
||||
x = guiLeft + 8;
|
||||
newChannelTF = new GuiTextField(getFontRenderer(), x, y, 103, 16);
|
||||
newChannelTF.setCanLoseFocus(false);
|
||||
newChannelTF.setMaxStringLength(32);
|
||||
newChannelTF.setFocused(true);
|
||||
|
||||
privateButton.onGuiInit();
|
||||
addButton.onGuiInit();
|
||||
selectPrivateB.onGuiInit();
|
||||
@@ -322,6 +318,7 @@ public class GuiHyperCube extends GuiContainerBase {
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
super.keyTyped(par1, par2);
|
||||
if(par2 == 1) {
|
||||
for (IGuiOverlay overlay : overlays) {
|
||||
if(overlay.isVisible()) {
|
||||
@@ -331,24 +328,13 @@ public class GuiHyperCube extends GuiContainerBase {
|
||||
}
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
newChannelTF.textboxKeyTyped(par1, par2);
|
||||
addButton.enabled = newChannelTF.getText().trim().length() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
newChannelTF.mouseClicked(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
newChannelTF.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) {
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/hyperCube.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
@@ -367,7 +353,6 @@ public class GuiHyperCube extends GuiContainerBase {
|
||||
selectPrivateB.enabled = chanSel;
|
||||
deletePrivateB.enabled = chanSel;
|
||||
|
||||
newChannelTF.drawTextBox();
|
||||
publicChannelList.drawScreen(mouseX, mouseY, partialTick);
|
||||
privateChannelList.drawScreen(mouseX, mouseY, partialTick);
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
private CheckBoxEIO enabledB;
|
||||
|
||||
private GuiTextField startTF;
|
||||
|
||||
private GuiTextField endTF;
|
||||
|
||||
private String titleStr;
|
||||
@@ -103,6 +102,22 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
enabledB.setUnselectedToolTip(Lang.localize("gui.disabled"));
|
||||
enabledB.setSelected(te.engineControlEnabled);
|
||||
|
||||
|
||||
x = MARGIN + getFontRenderer().getStringWidth(engineTxt2) + 4;
|
||||
int y = MARGIN + ICON_SIZE + ICON_SIZE + getFontRenderer().FONT_HEIGHT;
|
||||
startTF = new GuiTextField(getFontRenderer(), x, y, 28, 14);
|
||||
startTF.setCanLoseFocus(true);
|
||||
startTF.setMaxStringLength(3);
|
||||
startTF.setFocused(true);
|
||||
startTF.setText(INT_NF.format(te.asPercentInt(te.startLevel)));
|
||||
|
||||
y = y + getFontRenderer().FONT_HEIGHT + ICON_SIZE + ICON_SIZE + 4;
|
||||
x = MARGIN + getFontRenderer().getStringWidth(engineTxt5);
|
||||
endTF = new GuiTextField(getFontRenderer(), x, y, 28, 14);
|
||||
endTF.setCanLoseFocus(true);
|
||||
endTF.setMaxStringLength(3);
|
||||
endTF.setFocused(false);
|
||||
endTF.setText(INT_NF.format(te.asPercentInt(te.stopLevel)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,23 +126,6 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
|
||||
buttonList.clear();
|
||||
//enabledB.onGuiInit();
|
||||
|
||||
int x = guiLeft + MARGIN + getFontRenderer().getStringWidth(engineTxt2) + 4;
|
||||
int y = guiTop + MARGIN + ICON_SIZE + ICON_SIZE + getFontRenderer().FONT_HEIGHT;
|
||||
startTF = new GuiTextField(getFontRenderer(), x, y, 28, 14);
|
||||
startTF.setCanLoseFocus(true);
|
||||
startTF.setMaxStringLength(3);
|
||||
startTF.setFocused(true);
|
||||
startTF.setText(INT_NF.format(te.asPercentInt(te.startLevel)));
|
||||
|
||||
y = y + getFontRenderer().FONT_HEIGHT + ICON_SIZE + ICON_SIZE + 4;
|
||||
x = guiLeft + MARGIN + getFontRenderer().getStringWidth(engineTxt5);
|
||||
endTF = new GuiTextField(getFontRenderer(), x, y, 28, 14);
|
||||
endTF.setCanLoseFocus(true);
|
||||
endTF.setMaxStringLength(3);
|
||||
endTF.setFocused(false);
|
||||
endTF.setText(INT_NF.format(te.asPercentInt(te.stopLevel)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,20 +133,6 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
super.keyTyped(par1, par2);
|
||||
startTF.textboxKeyTyped(par1, par2);
|
||||
endTF.textboxKeyTyped(par1, par2);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
startTF.updateCursorCounter();
|
||||
endTF.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOverlayOffsetX() {
|
||||
return 0;
|
||||
@@ -157,10 +141,7 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int par3) {
|
||||
super.mouseClicked(x, y, par3);
|
||||
|
||||
startTF.mouseClicked(x, y, par3);
|
||||
endTF.mouseClicked(x, y, par3);
|
||||
|
||||
|
||||
x = (x - guiLeft);
|
||||
y = (y - guiTop);
|
||||
if(x > 200 && x < 220) {
|
||||
@@ -178,6 +159,7 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float ptick, int mouseX, int mouseY) {
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(ptick, mouseX, mouseY);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/powerMonitor.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
@@ -290,10 +272,6 @@ public class GuiPowerMonitor extends GuiContainerBase {
|
||||
txt = engineTxt3;
|
||||
x += MARGIN + endTF.getWidth() + 10;
|
||||
fontRenderer.drawString(txt, x, y, rgb, false);
|
||||
|
||||
startTF.drawTextBox();
|
||||
endTF.drawTextBox();
|
||||
|
||||
}
|
||||
|
||||
private void renderInfoTab(int sx, int sy) {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package crazypants.enderio.power;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
|
||||
public class EnergyProviderPI implements IPowerInterface {
|
||||
|
||||
private IEnergyProvider rfPower;
|
||||
|
||||
public EnergyProviderPI(IEnergyProvider powerReceptor) {
|
||||
rfPower = powerReceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDelegate() {
|
||||
return rfPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConduitConnect(ForgeDirection direction) {
|
||||
if(rfPower != null && direction != null) {
|
||||
return rfPower.canConnectEnergy(direction.getOpposite());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection dir) {
|
||||
if(rfPower != null && dir != null) {
|
||||
return rfPower.getEnergyStored(dir);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection dir) {
|
||||
if(rfPower != null && dir != null) {
|
||||
return rfPower.getMaxEnergyStored(dir);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPowerRequest(ForgeDirection dir) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinEnergyReceived(ForgeDirection dir) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int recieveEnergy(ForgeDirection opposite, int canOffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutputOnly() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInputOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import cofh.api.energy.IEnergyProvider;
|
||||
import cofh.api.energy.IEnergyReceiver;
|
||||
|
||||
public class PowerHandlerUtil {
|
||||
@@ -14,6 +15,8 @@ public class PowerHandlerUtil {
|
||||
public static IPowerInterface create(Object o) {
|
||||
if(o instanceof IEnergyHandler) {
|
||||
return new EnergyHandlerPI((IEnergyHandler) o);
|
||||
} else if (o instanceof IEnergyProvider) {
|
||||
return new EnergyProviderPI((IEnergyProvider) o);
|
||||
} else if(o instanceof IEnergyReceiver) {
|
||||
return new EnergyReceiverPI((IEnergyReceiver) o);
|
||||
} else if(o instanceof IEnergyConnection) {
|
||||
|
||||
@@ -111,9 +111,6 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
privateCB.onGuiInit();
|
||||
protectedCB.onGuiInit();
|
||||
|
||||
tf.xPosition = getGuiLeft() + 30;
|
||||
tf.yPosition = getGuiTop() + 10;
|
||||
tf.setCanLoseFocus(false);
|
||||
tf.setMaxStringLength(32);
|
||||
tf.setFocused(true);
|
||||
String txt = te.getLabel();
|
||||
@@ -134,19 +131,16 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
}
|
||||
this.mc.thePlayer.closeScreen();
|
||||
}
|
||||
tf.textboxKeyTyped(par1, par2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
tf.updateCursorCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int x, int y, int par3) {
|
||||
super.mouseClicked(x, y, par3);
|
||||
tf.mouseClicked(x, y, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -171,8 +165,6 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
|
||||
x = sx + col2x - fontRenderer.getStringWidth(publicStr) / 2;
|
||||
fontRenderer.drawStringWithShadow(publicStr, x, y, col);
|
||||
|
||||
tf.drawTextBox();
|
||||
checkLabelForChange();
|
||||
|
||||
}
|
||||
@@ -205,7 +197,6 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
BlockCoord bc = te.getLocation();
|
||||
PacketLabel p = new PacketLabel(bc.x, bc.y, bc.z, te.getLabel());
|
||||
PacketHandler.INSTANCE.sendToServer(p);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,7 +85,7 @@ public class BlockTelePad extends BlockTravelAnchor {
|
||||
if (tp.inNetwork) {
|
||||
if (!tp.isMaster()) {
|
||||
TileTelePad master = tp.getMaster();
|
||||
openGui(world, master.xCoord, master.yCoord, master.zCoord, entityPlayer, side);
|
||||
return openGui(world, master.xCoord, master.yCoord, master.zCoord, entityPlayer, side);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package crazypants.enderio.teleport.telepad;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
@@ -18,18 +23,28 @@ public class GuiTelePad extends GuiContainerBase implements IToggleableGui {
|
||||
private static final int ID_SWITCH_BUTTON = 99;
|
||||
|
||||
ToggleTravelButton switchButton;
|
||||
|
||||
|
||||
private World world;
|
||||
private TileTelePad te;
|
||||
|
||||
private GuiTextField x, y, z;
|
||||
|
||||
public GuiTelePad(InventoryPlayer playerInv, TileTelePad te, World world) {
|
||||
super(new ContainerTelePad(playerInv));
|
||||
this.world = world;
|
||||
this.te = te;
|
||||
|
||||
|
||||
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
x = new GuiTextField(fr, 7, 12, 90, 16);
|
||||
y = new GuiTextField(fr, 7, 32, 90, 16);
|
||||
z = new GuiTextField(fr, 7, 52, 90, 16);
|
||||
|
||||
textFields.addAll(Lists.newArrayList(x, y, z));
|
||||
|
||||
switchButton = new ToggleTravelButton(this, ID_SWITCH_BUTTON, 150, 10, IconEIO.IO_WHATSIT);
|
||||
switchButton.setToolTip(Lang.localize("gui.telepad.configure.travel"));
|
||||
|
||||
|
||||
this.ySize += 19;
|
||||
}
|
||||
|
||||
@@ -37,16 +52,24 @@ public class GuiTelePad extends GuiContainerBase implements IToggleableGui {
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
switchButton.onGuiInit();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/telePad.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderUtil.bindTexture("enderio:textures/gui/telePad.png");
|
||||
int sx = (width - xSize) / 2;
|
||||
int sy = (height - ySize) / 2;
|
||||
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(p_146976_1_, p_146976_2_, p_146976_3_);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,8 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei
|
||||
private TileTelePad master = null;
|
||||
|
||||
private boolean autoUpdate = false;
|
||||
|
||||
private BlockCoord target;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
@@ -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