2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.client.gui;
|
2013-08-02 09:16:38 +02:00
|
|
|
|
|
|
|
import mekanism.api.Object3D;
|
|
|
|
import mekanism.common.IRedstoneControl;
|
|
|
|
import mekanism.common.IRedstoneControl.RedstoneControl;
|
|
|
|
import mekanism.common.PacketHandler;
|
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
|
|
|
import mekanism.common.network.PacketRedstoneControl;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-08-02 09:16:38 +02:00
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
2013-08-26 02:54:34 +02:00
|
|
|
public class GuiRedstoneControl extends GuiElement
|
2013-08-02 09:16:38 +02:00
|
|
|
{
|
|
|
|
public GuiRedstoneControl(GuiContainer gui, TileEntity tile, ResourceLocation def)
|
|
|
|
{
|
2013-08-26 02:54:34 +02:00
|
|
|
super(MekanismUtils.getResource(ResourceType.GUI, "GuiRedstoneControl.png"), gui, tile, def);
|
2013-08-02 09:16:38 +02:00
|
|
|
}
|
|
|
|
|
2013-08-26 02:54:34 +02:00
|
|
|
@Override
|
2013-08-02 09:16:38 +02:00
|
|
|
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
|
|
|
|
{
|
2013-09-28 03:59:47 +02:00
|
|
|
mc.renderEngine.bindTexture(RESOURCE);
|
2013-08-02 09:16:38 +02:00
|
|
|
|
|
|
|
guiContainer.drawTexturedModalRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26);
|
|
|
|
|
|
|
|
IRedstoneControl control = (IRedstoneControl)tileEntity;
|
|
|
|
int renderX = 26 + (18*control.getControlType().ordinal());
|
|
|
|
|
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160)
|
|
|
|
{
|
|
|
|
guiContainer.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
guiContainer.drawTexturedModalRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18);
|
|
|
|
}
|
|
|
|
|
2013-09-28 03:59:47 +02:00
|
|
|
mc.renderEngine.bindTexture(defaultLocation);
|
2013-08-02 09:16:38 +02:00
|
|
|
}
|
|
|
|
|
2013-08-26 02:54:34 +02:00
|
|
|
@Override
|
2013-08-02 09:16:38 +02:00
|
|
|
public void renderForeground(int xAxis, int yAxis)
|
|
|
|
{
|
2013-09-28 03:59:47 +02:00
|
|
|
mc.renderEngine.bindTexture(RESOURCE);
|
2013-08-02 09:16:38 +02:00
|
|
|
|
|
|
|
IRedstoneControl control = (IRedstoneControl)tileEntity;
|
|
|
|
|
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160)
|
|
|
|
{
|
|
|
|
displayTooltip(control.getControlType().getDisplay(), xAxis, yAxis);
|
|
|
|
}
|
|
|
|
|
2013-09-28 03:59:47 +02:00
|
|
|
mc.renderEngine.bindTexture(defaultLocation);
|
2013-08-02 09:16:38 +02:00
|
|
|
}
|
|
|
|
|
2013-08-26 02:54:34 +02:00
|
|
|
@Override
|
2013-08-27 00:28:55 +02:00
|
|
|
public void preMouseClicked(int xAxis, int yAxis, int button) {}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mouseClicked(int xAxis, int yAxis, int button)
|
2013-08-02 09:16:38 +02:00
|
|
|
{
|
|
|
|
IRedstoneControl control = (IRedstoneControl)tileEntity;
|
|
|
|
|
2013-08-27 00:28:55 +02:00
|
|
|
if(button == 0)
|
2013-08-02 09:16:38 +02:00
|
|
|
{
|
2013-08-27 00:28:55 +02:00
|
|
|
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160)
|
|
|
|
{
|
|
|
|
RedstoneControl current = control.getControlType();
|
|
|
|
int ordinalToSet = current.ordinal() < (RedstoneControl.values().length-1) ? current.ordinal()+1 : 0;
|
|
|
|
|
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketRedstoneControl().setParams(Object3D.get(tileEntity), RedstoneControl.values()[ordinalToSet]));
|
|
|
|
}
|
2013-08-02 09:16:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|