2017-04-10 16:20:39 +02:00
|
|
|
/*
|
|
|
|
* This file is part of Industrial Wires.
|
|
|
|
* Copyright (C) 2016-2017 malte0811
|
|
|
|
*
|
|
|
|
* Industrial Wires is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Industrial Wires is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-04-09 16:59:57 +02:00
|
|
|
package malte0811.industrialWires.client.gui;
|
|
|
|
|
|
|
|
import malte0811.industrialWires.IndustrialWires;
|
|
|
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
2017-05-01 18:40:29 +02:00
|
|
|
import malte0811.industrialWires.client.gui.elements.GuiIntChooser;
|
|
|
|
import malte0811.industrialWires.containers.ContainerRSPanelConn;
|
2017-04-09 16:59:57 +02:00
|
|
|
import malte0811.industrialWires.network.MessageGUIInteract;
|
2017-05-01 18:40:29 +02:00
|
|
|
import net.minecraft.client.gui.Gui;
|
|
|
|
import net.minecraft.client.gui.inventory.GuiContainer;
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
import net.minecraft.client.renderer.RenderHelper;
|
2017-04-09 16:59:57 +02:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2017-05-01 18:40:29 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2017-04-09 16:59:57 +02:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
2017-05-01 18:40:29 +02:00
|
|
|
public class GuiRSPanelConn extends GuiContainer {
|
2017-04-09 16:59:57 +02:00
|
|
|
private TileEntityRSPanelConn te;
|
2017-05-01 18:40:29 +02:00
|
|
|
private GuiIntChooser chooser;
|
2017-05-11 16:39:20 +02:00
|
|
|
|
2017-04-12 15:55:37 +02:00
|
|
|
public GuiRSPanelConn(TileEntityRSPanelConn tile) {
|
2017-05-01 18:40:29 +02:00
|
|
|
super(new ContainerRSPanelConn(tile));
|
2017-04-09 16:59:57 +02:00
|
|
|
te = tile;
|
|
|
|
}
|
2017-05-11 16:39:20 +02:00
|
|
|
|
2017-04-09 16:59:57 +02:00
|
|
|
@Override
|
|
|
|
public void initGui() {
|
|
|
|
super.initGui();
|
2017-05-11 16:39:20 +02:00
|
|
|
chooser = new GuiIntChooser((width - 32) / 2, (height - 4) / 2, false, te.getRsId(), 2);
|
2017-05-01 18:40:29 +02:00
|
|
|
xSize = 64;
|
|
|
|
ySize = 64;
|
2017-05-11 16:39:20 +02:00
|
|
|
guiLeft = (width - xSize) / 2;
|
|
|
|
guiTop = (height - ySize) / 2;
|
2017-04-09 16:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-05-01 18:40:29 +02:00
|
|
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
|
|
|
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
|
|
chooser.click(mouseX, mouseY);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
|
|
|
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
|
|
GlStateManager.color(1, 1, 1, 1);
|
|
|
|
RenderHelper.disableStandardItemLighting();
|
|
|
|
chooser.drawChooser();
|
|
|
|
RenderHelper.enableStandardItemLighting();
|
2017-04-09 16:59:57 +02:00
|
|
|
}
|
|
|
|
|
2017-05-01 18:40:29 +02:00
|
|
|
private ResourceLocation textureLoc = new ResourceLocation(IndustrialWires.MODID, "textures/gui/rs_wire_controller.png");
|
2017-05-11 16:39:20 +02:00
|
|
|
|
2017-04-09 16:59:57 +02:00
|
|
|
@Override
|
2017-05-01 18:40:29 +02:00
|
|
|
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
2017-05-11 16:39:20 +02:00
|
|
|
GlStateManager.color(1, 1, 1, 1);
|
2017-05-01 18:40:29 +02:00
|
|
|
mc.getTextureManager().bindTexture(textureLoc);
|
|
|
|
Gui.drawModalRectWithCustomSizedTexture(guiLeft, guiTop, 0, 0, xSize, ySize, 64, 64);
|
2017-04-09 16:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doesGuiPauseGame() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-05-01 18:40:29 +02:00
|
|
|
@Override
|
|
|
|
public void onGuiClosed() {
|
|
|
|
super.onGuiClosed();
|
|
|
|
onChange();
|
|
|
|
}
|
|
|
|
|
2017-04-09 16:59:57 +02:00
|
|
|
private void onChange() {
|
2017-05-11 16:39:20 +02:00
|
|
|
if (chooser.getValue() != te.getRsId()) {
|
2017-04-09 16:59:57 +02:00
|
|
|
NBTTagCompound nbt = new NBTTagCompound();
|
2017-05-01 18:40:29 +02:00
|
|
|
nbt.setInteger("rsId", chooser.getValue());
|
2017-04-09 16:59:57 +02:00
|
|
|
IndustrialWires.packetHandler.sendToServer(new MessageGUIInteract(te, nbt));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|