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.brokenmoon.afloydwiremod.tileentity.ChipTileEntity; import net.minecraft.src.EntityPlayer; import net.minecraft.src.GuiButton; import net.minecraft.src.GuiScreen; public class GuiSettings extends GuiScreen { private AbstractWireTileEntity wireEntity; @Override public void initGui() { //this.height - 240 is top //This.width / 2 - 214 is left //Inputs if(wireEntity instanceof ChipTileEntity){ switch(((ChipTileEntity) wireEntity).mode){ case "constant": initConst(); break; case "Pulse": initPulse(); break; } } } private void initPulse() { this.controlList.add(new GuiButton(1, this.width /2 - 100, this.height/2 - 20 - 10, "+")); this.controlList.add(1,new GuiButton(0, this.width /2 - 100, this.height/2 - 10, ((ChipTileEntity)wireEntity).tickAmount + "")); this.controlList.add(new GuiButton(2, this.width /2 - 100, this.height/2 + 20 - 10, "-")); } public void initConst(){ this.controlList.add(new GuiButton(1, this.width /2 - 100, this.height/2 - 20 - 10, "+")); this.controlList.add(1,new GuiButton(0, this.width /2 - 100, this.height/2 - 10 , wireEntity.outputs[0].floatvalue + "")); this.controlList.add(new GuiButton(2, this.width /2 - 100, this.height/2 + 20 - 10, "-")); } public GuiSettings(EntityPlayer player, AbstractWireTileEntity wireEntity) { super.initGui(); this.wireEntity = wireEntity; } @Override protected void actionPerformed(GuiButton guiButton){ if(wireEntity instanceof ChipTileEntity){ switch(((ChipTileEntity)wireEntity).mode){ case "constant": constAction(guiButton); break; case "Pulse": pulseAction(guiButton); break; } } } private void pulseAction(GuiButton guiButton) { if(guiButton.id == 1){ ((ChipTileEntity)wireEntity).tickAmount++; } if(guiButton.id == 2){ ((ChipTileEntity)wireEntity).tickAmount--; } this.controlList.get(1).displayString = ((ChipTileEntity)wireEntity).tickAmount + ""; } private void constAction(GuiButton guiButton) { if(guiButton.id == 1){ wireEntity.outputs[0].floatvalue++; } if(guiButton.id == 2){ wireEntity.outputs[0].floatvalue--; } this.controlList.get(1).displayString = wireEntity.outputs[0].floatvalue + ""; wireEntity.updateIO(); } }