package org.teamavion.pcomp.gui; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiTextField; import net.minecraft.nbt.NBTTagCompound; import org.lwjgl.input.Keyboard; import org.teamavion.pcomp.PComp; import org.teamavion.pcomp.net.DataListener; import org.teamavion.pcomp.tile.TileEntityComputer; import org.teamavion.util.support.NetworkChannel; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @SuppressWarnings({"unchecked", "WeakerAccess"}) public class GUIComputer extends GuiScreen implements DataListener>{ protected final int viewportMin = -90, viewportMax = 45, maxInputLines = 128, textFieldLen = 240, textColor = 0xFFFFFF; protected final long keyPressTimeout = 0; // timeout period between keypresses to minimize spam protected final ArrayList viewportInput = new ArrayList<>(); protected final TileEntityComputer computer; protected boolean viewportUpdated = true; protected int selected = 0, viewportSelect = 0; protected long keyPressTime = 0; protected GuiTextField[] inputLines; protected GuiButton button; public GUIComputer(TileEntityComputer computer){ this.computer = computer; NBTTagCompound n = new NBTTagCompound(); n.setString("update", ""); PComp.instance.channel.sendToServer(new NetworkChannel.WorldEvent(computer.getPos(), computer.getWorld().provider.getDimension(), n)); } @Override public void drawBackground(int tint) { super.drawBackground(tint); } @Override public void initGui() { inputLines = new GuiTextField[maxInputLines]; for(int i = 0; i0) --viewportSelect; else if(selected>0){ viewportUpdated = true; for(GuiTextField t : inputLines) t.yPosition += 15; } if(selected>0) --selected; inputLines[selected].setFocused(true); } else if(keyCode==Keyboard.KEY_DOWN){ inputLines[selected].setFocused(false); if(viewportSelect+1=inputLines[selected+1].getText().length()){ inputLines[selected].setText(inputLines[selected].getText()+inputLines[selected+1].getText()); for(int i = selected+1; i+1= height / 2 + viewportMin) viewportInput.add(t); viewportUpdated = false; } for(int i = 0; i data) { for(int i = 0; i