|
|
|
package net.brokenmoon.afloydwiremod.gui;
|
|
|
|
|
|
|
|
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
|
|
|
import net.brokenmoon.afloydwiremod.api.WireConnection;
|
|
|
|
import net.brokenmoon.afloydwiremod.item.ToolWiring;
|
|
|
|
import net.minecraft.src.EntityPlayer;
|
|
|
|
import net.minecraft.src.GuiButton;
|
|
|
|
import net.minecraft.src.GuiScreen;
|
|
|
|
import org.lwjgl.input.Mouse;
|
|
|
|
|
|
|
|
public class GuiWiring extends GuiScreen {
|
|
|
|
private ToolWiring tool;
|
|
|
|
|
|
|
|
private int x;
|
|
|
|
private int y;
|
|
|
|
private int z;
|
|
|
|
private AbstractWireTileEntity wireEntity;
|
|
|
|
@Override
|
|
|
|
public void initGui() {
|
|
|
|
//this.height - 240 is top
|
|
|
|
//This.width / 2 - 214 is left
|
|
|
|
//Inputs
|
|
|
|
if(wireEntity.inputs != null && this.tool.type.equals("output")) {
|
|
|
|
for (int i = 0; i < wireEntity.inputs.length; i++) {
|
|
|
|
this.controlList.add(new GuiButtonExtended(i + 1, this.width, wireEntity.inputs[i].buttonString, "Input", wireEntity.inputs[i].slot));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Outputs
|
|
|
|
if(wireEntity.outputs != null && !this.tool.type.equals("output")) {
|
|
|
|
for (int i = 0; i < wireEntity.outputs.length; i++) {
|
|
|
|
this.controlList.add(new GuiButtonExtended(i + 1, this.width, wireEntity.outputs[i].buttonString, "Output", wireEntity.outputs[i].slot));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawScreen(int x, int y, float renderPartialTicks) {
|
|
|
|
int wheel = Mouse.getDWheel();
|
|
|
|
for (int i = 0; i < this.controlList.size(); ++i) {
|
|
|
|
GuiButton guibutton = this.controlList.get(i);
|
|
|
|
if(wheel > 0)
|
|
|
|
guibutton.yPosition = guibutton.yPosition + 1;
|
|
|
|
if(wheel < 0)
|
|
|
|
guibutton.yPosition = guibutton.yPosition - 1;
|
|
|
|
if(guibutton.yPosition >= 50 && guibutton.yPosition <= 200)
|
|
|
|
guibutton.drawButton(this.mc, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public GuiWiring(EntityPlayer player, ToolWiring tool, AbstractWireTileEntity wireEntity, int x, int y, int z) {
|
|
|
|
super.initGui();
|
|
|
|
this.tool = tool;
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
|
|
|
this.z = z;
|
|
|
|
this.wireEntity = wireEntity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void actionPerformed(GuiButton guiButton){
|
|
|
|
this.actionPerformed((GuiButtonExtended)guiButton);
|
|
|
|
}
|
|
|
|
protected void actionPerformed(GuiButtonExtended guibutton) {
|
|
|
|
if(this.tool.type.equals("unpaired")) {
|
|
|
|
if (guibutton.type.equals("Input")) {
|
|
|
|
this.tool.type = "input";
|
|
|
|
this.tool.slot = guibutton.slot;
|
|
|
|
this.tool.x = x;
|
|
|
|
this.tool.y = y;
|
|
|
|
this.tool.z = z;
|
|
|
|
} else if (guibutton.type.equals("Output")) {
|
|
|
|
this.tool.type = "output";
|
|
|
|
this.tool.slot = guibutton.slot;
|
|
|
|
this.tool.x = x;
|
|
|
|
this.tool.y = y;
|
|
|
|
this.tool.z = z;
|
|
|
|
}
|
|
|
|
} else if(this.tool.type.equals("output")) {
|
|
|
|
this.wireEntity.inputs[guibutton.slot].wire = new WireConnection(tool.x, tool.y, tool.z, guibutton.slot, tool.slot);
|
|
|
|
tool.type = "unpaired";
|
|
|
|
}
|
|
|
|
this.mc.displayGuiScreen(null);
|
|
|
|
}
|
|
|
|
}
|